mitao
2024-09-21 f44e4d609e7efaed9eac545137970b1e334f8106
ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/controller/forepart/ForepartAuctionSalesroomController.java
@@ -1,34 +1,40 @@
package com.ruoyi.auction.controller.forepart;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.auction.mapper.AuctionBondJlMapper;
import com.ruoyi.auction.mapper.AuctionGoodsMapper;
import com.ruoyi.auction.service.IAuctionGoodsService;
import com.ruoyi.auction.service.IAuctionSalesroomGoodsService;
import com.ruoyi.auction.service.IAuctionSalesroomService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.page.PageDTO;
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.dto.AppMiniLoginDTO;
import com.ruoyi.system.api.domain.dto.AuctionSalesroomDTO;
import com.ruoyi.system.api.domain.dto.ForepartAuctionBidRecordDTO;
import com.ruoyi.auction.service.IAuctionSalesroomGoodsService;
import com.ruoyi.system.api.domain.dto.MemberAuctionSalesroomBondDTO;
import com.ruoyi.system.api.domain.dto.MemberAuctionSalesroomDTO;
import com.ruoyi.system.api.domain.vo.ForepartAuctionSalesroomVO;
import com.ruoyi.system.api.domain.vo.MemberAuctionSalesroomInfoVO;
import com.ruoyi.system.api.domain.vo.MemberAuctionSalesroomVO;
import com.ruoyi.system.api.domain.AuctionSalesroom;
import com.ruoyi.auction.service.IAuctionSalesroomService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.page.PageDTO;
import com.ruoyi.system.api.domain.AppMiniLoginVO;
import com.ruoyi.system.api.domain.dto.AppMiniLoginDTO;
import com.ruoyi.system.api.domain.vo.PayInfoVO;
import com.ruoyi.system.api.domain.vo.WdMemberAuctionSalesroomVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * <p>
@@ -38,6 +44,7 @@
 * @author mitao
 * @since 2024-05-16
 */
@Slf4j
@RestController
@RequestMapping("/forepart/auction-salesroom")
@Api(value = "拍卖场相关接口", tags = "拍卖场相关接口", description = "拍卖场相关接口")
@@ -52,6 +59,9 @@
    @Resource
    private AuctionGoodsMapper AuctionGoodsMapper;
    @Resource
    private AuctionBondJlMapper  auctionBondJlMapper;
    /**
     * 拍卖大屏获取拍卖信息
@@ -114,15 +124,62 @@
   @PostMapping("/SaveSignUpNow")
    @ApiOperation(value = "用户端-拍卖立即报名")
    public R<PayInfoVO> SaveSignUpNow(@RequestBody MemberAuctionSalesroomBondDTO memberAuctionSalesroomBondDTO) {
      if (memberAuctionSalesroomBondDTO.getBondType()==1){
       log.info("=================================开始拍卖报名=================================");
       if (memberAuctionSalesroomBondDTO.getBondType() == 1) {
          AuctionGoods auctionGoods = AuctionGoodsMapper.selectById(memberAuctionSalesroomBondDTO.getAuctionGoodsId());
          if (auctionGoods.getEndTime().isAfter(LocalDateTime.now())){
              throw new ServiceException("商品拍卖已结束");
          }
          if (auctionGoods.getListingStatus().getCode()==1){
              throw new ServiceException("商品拍卖下线");
          }
           LambdaQueryWrapper<AuctionBondJl> wrapper = Wrappers.lambdaQuery();
           wrapper.eq(AuctionBondJl::getAuctionGoodsId,
                   memberAuctionSalesroomBondDTO.getAuctionGoodsId());
           wrapper.eq(AuctionBondJl::getMemberId, memberAuctionSalesroomBondDTO.getMemberId());
           wrapper.eq(AuctionBondJl::getIsState, 0);
           AuctionBondJl auctionBondJl = auctionBondJlMapper.selectOne(wrapper);
           if (Objects.nonNull(auctionBondJl)) {
               throw new ServiceException("你已报名");
           }
           log.info("auctionGoods:{}", auctionGoods);
           if (auctionGoods.getBond() == null
                   || auctionGoods.getBond().compareTo(BigDecimal.ZERO) == 0) {
               auctionBondJl = new AuctionBondJl();
               auctionBondJl.setAuctionGoodsId(memberAuctionSalesroomBondDTO.getAuctionGoodsId());
               auctionBondJl.setIsState(0);
               auctionBondJl.setBondType(memberAuctionSalesroomBondDTO.getBondType());
               auctionBondJl.setMemberId(memberAuctionSalesroomBondDTO.getMemberId());
               auctionBondJlMapper.insert(auctionBondJl);
           }
      }else{
          AuctionSalesroom byId = iAuctionSalesroomService.getById(memberAuctionSalesroomBondDTO.getAuctionSalesroomId());
          if(byId==null){
              LambdaQueryWrapper<AuctionSalesroom> auctionSalesroomWrapper = Wrappers.lambdaQuery();
              auctionSalesroomWrapper.eq(AuctionSalesroom::getAuctionSalesroomNo,
                      memberAuctionSalesroomBondDTO.getAuctionSalesroomId());
              auctionSalesroomWrapper.eq(AuctionSalesroom::getDelFlag, 0);
              byId = iAuctionSalesroomService.getOne(auctionSalesroomWrapper);
          }
           memberAuctionSalesroomBondDTO.setAuctionSalesroomId(byId.getId());
           LambdaQueryWrapper<AuctionBondJl> wrapper = Wrappers.lambdaQuery();
           wrapper.eq(AuctionBondJl::getAuctionSalesroomId,
                   memberAuctionSalesroomBondDTO.getAuctionSalesroomId());
           wrapper.eq(AuctionBondJl::getMemberId, memberAuctionSalesroomBondDTO.getMemberId());
           wrapper.eq(AuctionBondJl::getIsState, 0);
           AuctionBondJl auctionBondJl = auctionBondJlMapper.selectOne(wrapper);
           if (Objects.nonNull(auctionBondJl)) {
               throw new ServiceException("你已报名");
           }
           log.info("AuctionSalesroom:{}", byId);
           if (byId.getBond() == null || byId.getBond().compareTo(BigDecimal.ZERO) == 0) {
               auctionBondJl = new AuctionBondJl();
               auctionBondJl.setAuctionSalesroomId(
                       memberAuctionSalesroomBondDTO.getAuctionSalesroomId());
               auctionBondJl.setIsState(0);
               auctionBondJl.setBondType(memberAuctionSalesroomBondDTO.getBondType());
               auctionBondJl.setMemberId(memberAuctionSalesroomBondDTO.getMemberId());
               auctionBondJlMapper.insert(auctionBondJl);
           }
      }
       PayInfoVO payInfoVO = iAuctionSalesroomService.SaveSignUpNow(memberAuctionSalesroomBondDTO);
       return R.ok(payInfoVO);
@@ -133,6 +190,36 @@
    @ApiOperation(value = "用户端-拍卖取消报名")
    public R CancelSignUpNow(@RequestBody MemberAuctionSalesroomBondDTO memberAuctionSalesroomBondDTO) {
        iAuctionSalesroomService.CancelSignUpNow(memberAuctionSalesroomBondDTO);
       if (memberAuctionSalesroomBondDTO.getBondType()==2){
           AuctionSalesroom byId = iAuctionSalesroomService.getById(memberAuctionSalesroomBondDTO.getAuctionSalesroomId());
           if(byId==null){
               LambdaQueryWrapper<AuctionSalesroom> wrapper= Wrappers.lambdaQuery();
               wrapper.eq(AuctionSalesroom::getAuctionSalesroomNo,memberAuctionSalesroomBondDTO.getAuctionSalesroomId());
               wrapper.eq(AuctionSalesroom::getDelFlag,0);
               byId =iAuctionSalesroomService.getOne(wrapper);
               memberAuctionSalesroomBondDTO.setAuctionSalesroomId(byId.getId());
           }
           LambdaQueryWrapper<AuctionBondJl> wrapper=Wrappers.lambdaQuery();
           wrapper.eq(AuctionBondJl::getAuctionSalesroomId,byId.getId());
           wrapper.eq(AuctionBondJl::getMemberId,memberAuctionSalesroomBondDTO.getMemberId());
           wrapper.eq(AuctionBondJl::getIsState,0);
           AuctionBondJl auctionSalesroom = auctionBondJlMapper.selectOne(wrapper);
           if (auctionSalesroom!=null){
               auctionSalesroom.setIsState(1);
               auctionBondJlMapper.updateById(auctionSalesroom);
           }
       }else{
           LambdaQueryWrapper<AuctionBondJl> wrapper=Wrappers.lambdaQuery();
           wrapper.eq(AuctionBondJl::getAuctionGoodsId,memberAuctionSalesroomBondDTO.getAuctionGoodsId());
           wrapper.eq(AuctionBondJl::getMemberId,memberAuctionSalesroomBondDTO.getMemberId());
           wrapper.eq(AuctionBondJl::getIsState,0);
           AuctionBondJl auctionSalesroom = auctionBondJlMapper.selectOne(wrapper);
           auctionSalesroom.setIsState(1);
           auctionBondJlMapper.updateById(auctionSalesroom);
       }
        return R.ok( );
    }