mitao
2024-07-29 2a97ecf8833f24dfbd5bf251e1fc1bdb632bbefb
ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomServiceImpl.java
@@ -19,6 +19,7 @@
import com.ruoyi.auction.controller.management.dto.MgtScreenBidPage;
import com.ruoyi.auction.controller.management.dto.MgtScreenSalesroomGoodsDTO;
import com.ruoyi.auction.controller.management.dto.MgtScreenVideoDTO;
import com.ruoyi.auction.controller.management.vo.AuctionSalesroomQrCodeVO;
import com.ruoyi.auction.controller.management.vo.MgtAuctionBidRecordVO;
import com.ruoyi.auction.controller.management.vo.MgtAuctionSalesroomGoodsVO;
import com.ruoyi.auction.controller.management.vo.MgtAuctionSalesroomScreenVO;
@@ -242,12 +243,12 @@
    @Override
    public AuctionSalesroom getAuctionBidRecordOne(ForepartAuctionBidRecordDTO arepartAuctionBidRecordDTO) {
        R<SysUser> r=sysUserClient.queryUserByPhone(arepartAuctionBidRecordDTO.getPhone());
        R<SysUser> r=sysUserClient.queryUserByPhone1(arepartAuctionBidRecordDTO.getPhone());
        SysUser sysUser=r.getData();
        if (sysUser==null){
            throw new ServiceException("手机号未注册");
        }
        if (sysUser.getStatus().equals(1)){
        if (sysUser.getStatus().equals("1")){
            throw new ServiceException("该拍卖师账号停用");
        }
@@ -259,9 +260,12 @@
        wrapper.eq(AuctionSalesroom::getAuctionSalesroomNo,arepartAuctionBidRecordDTO.getAuctionSalesroomQrcode());
        wrapper.eq(AuctionSalesroom::getDelFlag,0);
        AuctionSalesroom auctionBidRecord = this.getOne(wrapper);
        if(auctionBidRecord.getType().getCode()==0){
            throw new ServiceException("当前扫码是线下拍卖会");
        if (auctionBidRecord!=null){
            if(auctionBidRecord.getType().getCode()==0){
                throw new ServiceException("当前扫码是线下拍卖会");
            }
        }
        return auctionBidRecord;
    }
@@ -408,12 +412,12 @@
            List<OrderAuctionBond> data1 = orderClient.getOrderAuctionBondList1(memberAuctionSalesroomDTO1, SecurityConstants.INNER).getData();
            if(data1!=null){
                memberAuctionSalesroomVO.setApplyNum(data1.size());
                List.add(memberAuctionSalesroomVO);
            }else{
                memberAuctionSalesroomVO.setApplyNum(0);
            }
            List.add(memberAuctionSalesroomVO);
        }
        page.setRecords(List);
        return PageDTO.of(page);
@@ -427,6 +431,7 @@
            wrapper.eq(AuctionSalesroom::getAuctionSalesroomNo,memberAuctionSalesroomDTO.getAuctionSalesroomId());
            wrapper.eq(AuctionSalesroom::getDelFlag,0);
            byId =this.getOne(wrapper);
            memberAuctionSalesroomDTO.setAuctionSalesroomId(byId.getId());
        }
        if (byId.getType().getCode()==0){
@@ -446,6 +451,7 @@
        memberAuctionSalesroomInfoVO.setStartTime(byId.getStartTime());
        memberAuctionSalesroomInfoVO.setStatus(byId.getStatus());
        memberAuctionSalesroomInfoVO.setCoverPic(byId.getCoverPic());
        List<OrderAuctionBond> data = orderClient.getOrderAuctionBondList1(memberAuctionSalesroomDTO, SecurityConstants.INNER).getData();
        if (data.size()>0){
            memberAuctionSalesroomInfoVO.setIsApply(2);
@@ -567,6 +573,15 @@
    @Override
    public void CancelSignUpNow(MemberAuctionSalesroomBondDTO memberAuctionSalesroomBondDTO) {
        if (memberAuctionSalesroomBondDTO.getBondType()==2){
            AuctionSalesroom byId = this.getById(memberAuctionSalesroomBondDTO.getAuctionSalesroomId());
            if(byId==null){
                LambdaQueryWrapper<AuctionSalesroom> wrapper= Wrappers.lambdaQuery();
                wrapper.eq(AuctionSalesroom::getAuctionSalesroomNo,memberAuctionSalesroomBondDTO.getAuctionSalesroomId());
                wrapper.eq(AuctionSalesroom::getDelFlag,0);
                byId =this.getOne(wrapper);
                memberAuctionSalesroomBondDTO.setAuctionSalesroomId(byId.getId());
            }
            OrderAuctionBond orderAuctionBond = orderClient.getOrderAuctionBondone(memberAuctionSalesroomBondDTO, SecurityConstants.INNER).getData();
            List<RefundDTO> refundDTOList = new ArrayList<>();
@@ -635,6 +650,14 @@
            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();
@@ -883,7 +906,15 @@
    @Override
    public String getQrCode(Long id) throws Exception {
        AuctionSalesroom auctionSalesroom = this.getById(id);
        String auctionSalesroomNo = auctionSalesroom.getAuctionSalesroomNo();
        if (StringUtils.isBlank(auctionSalesroom.getQrCode())) {
            AuctionSalesroomQrCodeVO vo = new AuctionSalesroomQrCodeVO();
            vo.setAuctionSalesroomNo(auctionSalesroom.getAuctionSalesroomNo());
            vo.setType(auctionSalesroom.getType().getCode());
            String url = remoteFileService.obsUpload(
                    CreateQrCode.createQRCodeStream(objectMapper.writeValueAsString(vo))).getData();
            auctionSalesroom.setQrCode(url);
            this.updateById(auctionSalesroom);
        }
        return auctionSalesroom.getQrCode();
    }
@@ -919,8 +950,11 @@
            // 生成唯一编号
            Long nextId = IDhelper.getNextId();
            auctionSalesroom.setAuctionSalesroomNo(nextId.toString());
            AuctionSalesroomQrCodeVO vo = new AuctionSalesroomQrCodeVO();
            vo.setAuctionSalesroomNo(nextId.toString());
            vo.setType(auctionSalesroom.getType().getCode());
            String url = remoteFileService.obsUpload(
                    CreateQrCode.createQRCodeStream(nextId.toString())).getData();
                    CreateQrCode.createQRCodeStream(objectMapper.writeValueAsString(vo))).getData();
            auctionSalesroom.setQrCode(url);
            // 添加
            this.save(auctionSalesroom);
@@ -944,6 +978,15 @@
                throw new ServiceException("该拍卖场已结束,不能编辑");
            }
            auctionSalesroom.setId(auctionSalesroomOrg.getId());
            if (!auctionSalesroomOrg.getType().equals(auctionSalesroom.getType())) {
                AuctionSalesroomQrCodeVO vo = new AuctionSalesroomQrCodeVO();
                vo.setAuctionSalesroomNo(auctionSalesroomOrg.getAuctionSalesroomNo());
                vo.setType(auctionSalesroom.getType().getCode());
                String url = remoteFileService.obsUpload(
                                CreateQrCode.createQRCodeStream(objectMapper.writeValueAsString(vo)))
                        .getData();
                auctionSalesroom.setQrCode(url);
            }
            this.updateById(auctionSalesroom);
            List<AuctionSalesroomGoods> list = auctionSalesroomGoodsMapper.selectList(
                    Wrappers.<AuctionSalesroomGoods>lambdaQuery()
@@ -984,9 +1027,7 @@
        Set<Long> goodsSkuIdList = null;
        goodsSkuIdList = data.stream().map(OrderAuctionBond::getAuctionSalesroomId)
                    .collect(Collectors.toSet());
        Page<AuctionSalesroom> page = new Page<>();
        page.setSize(memberAuctionSalesroomDTO.getPageSize());
        page.setCurrent(memberAuctionSalesroomDTO.getPageCurr());
       /* MemberAuctionSalesroomWdDTO memberAuctionSalesroomWdDTO=new MemberAuctionSalesroomWdDTO();
        if (goodsSkuIdList.size()>0){
            memberAuctionSalesroomWdDTO.setGoodsSkuIdList(goodsSkuIdList);
@@ -1005,6 +1046,9 @@
        }*/
        Page<AuctionSalesroom> page = new Page<>();
        page.setSize(memberAuctionSalesroomDTO.getPageSize());
        page.setCurrent(memberAuctionSalesroomDTO.getPageCurr());
        LambdaQueryWrapper<AuctionSalesroom> wrapper1=Wrappers.lambdaQuery();
        if (goodsSkuIdList.size()>0){
            wrapper1.in(AuctionSalesroom::getId,goodsSkuIdList);
@@ -1027,22 +1071,17 @@
                "        WHEN status = 2 THEN 3\n" +
                "        END,status");
        Page<AuctionSalesroom> auctionSalesroomList=this.page(page,wrapper1);
        Page<AuctionSalesroom> auctionSalesroomList=this.page(Page.of(memberAuctionSalesroomDTO.getPageCurr(),memberAuctionSalesroomDTO.getPageSize()),wrapper1);
        PageDTO<WdMemberAuctionSalesroomVO> wdMemberAuctionSalesroomVOPageDTO = PageDTO.of(auctionSalesroomList, WdMemberAuctionSalesroomVO.class);
        List<WdMemberAuctionSalesroomVO> list = wdMemberAuctionSalesroomVOPageDTO.getList();
        for (WdMemberAuctionSalesroomVO auctionSalesroom:list){
            WdMemberAuctionSalesroomVO  memberAuctionSalesroomVO=new WdMemberAuctionSalesroomVO();
            memberAuctionSalesroomVO.setSalesroomName(auctionSalesroom.getSalesroomName());
            memberAuctionSalesroomVO.setDescription(auctionSalesroom.getDescription());
            memberAuctionSalesroomVO.setStatus(auctionSalesroom.getStatus());
            memberAuctionSalesroomVO.setSalesroomId(auctionSalesroom.getId());
            memberAuctionSalesroomVO.setCoverPic(auctionSalesroom.getCoverPic());
            auctionSalesroom.setSalesroomId(auctionSalesroom.getId());
            MemberAuctionSalesroomDTO memberAuctionSalesroomDTO1=new MemberAuctionSalesroomDTO();
            memberAuctionSalesroomDTO1.setAuctionSalesroomId(auctionSalesroom.getSalesroomId());
            memberAuctionSalesroomDTO1.setMemberId(auctionSalesroom.getId());
            memberAuctionSalesroomDTO1.setAuctionSalesroomId(auctionSalesroom.getId());
            memberAuctionSalesroomDTO1.setMemberId(MemberAuctionSalesroomDTO.getMemberId());
            List<OrderAuctionBond> data1 = orderClient.getOrderAuctionBondList1(memberAuctionSalesroomDTO1, SecurityConstants.INNER).getData();
            if (data1.size()>0){
                memberAuctionSalesroomVO.setBondTime(data1.get(0).getCreateTime());
                auctionSalesroom.setBondTime(data1.get(0).getCreateTime());
            }
        }
        return wdMemberAuctionSalesroomVOPageDTO;
@@ -1168,11 +1207,10 @@
                        AuctionSalesroom::getSalesroomName, query.getSalesroomName())
                .eq(StringUtils.isNotNull(query.getStatus()), AuctionSalesroom::getStatus,
                        query.getStatus())
                .ne(AuctionSalesroom::getStatus, AuctionStartStatusEnum.ENDED)
                .between(StringUtils.isNotNull(query.getStartTime()) && StringUtils.isNotNull(
                                query.getEndTime()), AuctionSalesroom::getStartTime, query.getStartTime(),
                        query.getEndTime())
                .orderByAsc(AuctionSalesroom::getStartTime)
                .orderByDesc(AuctionSalesroom::getCreateTime)
                .page(new Page<>(query.getPageCurr(), query.getPageSize()));
        List<AuctionSalesroom> records = page.getRecords();
        if (StringUtils.isNull(records)) {
@@ -1218,7 +1256,7 @@
                vo.setAuctionSalesroomGoodsVOS(collect);
                if (StringUtils.isNotNull(vo.getCurrentAuctionSalesroomGoods())) {
                    int index = collect.indexOf(vo.getCurrentAuctionSalesroomGoods());
                    if (collect.size() > 1) {
                    if (collect.size() > 1 && index < collect.size() - 1) {
                        vo.setNextAuctionSalesroomGoods(collect.get(index + 1));
                    }
                    // 分页查询当前拍品出价信息
@@ -1333,8 +1371,8 @@
    public PageDTO<MgtAuctionSalesroomGoodsVO> backupGoods(MgtAuctionSalesroomGoodsQuery query) {
        Page<AuctionSalesroomGoods> page = new Page<>(query.getPageCurr(), query.getPageSize());
        Set<Long> goodsSkuIdSet = null;
        if (StringUtils.isNotBlank(query.getGoodsName())) {
            List<GoodsSku> data = goodsSkuClient.getGoodsByName(query.getGoodsName(),
        if (StringUtils.isNotBlank(query.getGoodsSkuName())) {
            List<GoodsSku> data = goodsSkuClient.getGoodsByName(query.getGoodsSkuName(),
                    SecurityConstants.INNER).getData();
            if (StringUtils.isNotEmpty(data)) {
                goodsSkuIdSet = data.stream().map(GoodsSku::getId)
@@ -1409,7 +1447,7 @@
                Wrappers.lambdaQuery(AuctionBidRecord.class)
                        .eq(AuctionBidRecord::getAuctionSalesroomId,
                                auctionSalesroomGoods.getAuctionSalesroomId())
                        .eq(AuctionBidRecord::getTargetId, auctionSalesroomGoods.getGoodsSkuId())
                        .eq(AuctionBidRecord::getTargetId, auctionSalesroomGoods.getId())
                        .eq(AuctionBidRecord::getAuctionType, AuctionOrderTypeEnum.AUCTION_ITEMS)
                        .orderByDesc(AuctionBidRecord::getLastBidAmount));
        if (CollUtils.isNotEmpty(auctionBidRecordList)) {
@@ -1417,11 +1455,15 @@
            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 < auctionSalesroomGoods.getSalesroomStock(); i++) {
                for (int i = 0; i < auctionBidRecordList.size(); i++) {
                    AuctionBidRecord auctionBidRecord = auctionBidRecordList.get(i);
                    auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL);
                    auctionBidRecordMapper.updateById(auctionBidRecord);
                    auctionBidRecords.add(auctionBidRecord);
                }
                // 没有出价记录,回退库存
@@ -1608,7 +1650,6 @@
    public void stopCurrentAuctionSalesroom(Long auctionSalesroomId)
            throws JsonProcessingException {
        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(
@@ -1624,19 +1665,18 @@
        auctionSalesroom.setStatus(AuctionStartStatusEnum.ENDED);
        auctionSalesroom.setEndTime(LocalDateTime.now());
        auctionSalesroomMapper.updateById(auctionSalesroom);
        auctionSalesroomGoods = auctionSalesroomGoods.stream()
                .filter(goods -> goods.getStatus().equals(AuctionGoodsStatusEnum.WAITING)).collect(
                        Collectors.toList());
        if (StringUtils.isNotEmpty(auctionSalesroomGoods)) {
            List<GoodsStockUpdDTO> dtoList = new ArrayList<>();
            for (AuctionSalesroomGoods salesroomGoods : auctionSalesroomGoods) {
                salesroomGoods.setStatus(AuctionGoodsStatusEnum.ENDED);
                // 等待中的商品退库存
                if (salesroomGoods.getStatus().equals(AuctionGoodsStatusEnum.WAITING)) {
                    GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO();
                    goodsStockUpdDTO.setGoodsSkuId(salesroomGoods.getGoodsSkuId());
                    goodsStockUpdDTO.setAuctionStock(salesroomGoods.getSalesroomStock());
                    dtoList.add(goodsStockUpdDTO);
                }
                GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO();
                goodsStockUpdDTO.setGoodsSkuId(salesroomGoods.getGoodsSkuId());
                goodsStockUpdDTO.setAuctionStock(salesroomGoods.getSalesroomStock());
                dtoList.add(goodsStockUpdDTO);
            }
            // 批量更新商品库存
            auctionSalesroomGoodsMapper.updateBatchById(auctionSalesroomGoods);