|
@@ -12,6 +12,7 @@ import cn.hobbystocks.auc.service.DepositOrderService;
|
|
|
import cn.hobbystocks.auc.service.IAuctionService;
|
|
import cn.hobbystocks.auc.service.IAuctionService;
|
|
|
import cn.hobbystocks.auc.service.ILotService;
|
|
import cn.hobbystocks.auc.service.ILotService;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -21,7 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
-import java.util.UUID;
|
|
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
public class DepositOrderServiceImpl extends ServiceImpl<DepositOrderMapper, DepositOrder> implements DepositOrderService {
|
|
public class DepositOrderServiceImpl extends ServiceImpl<DepositOrderMapper, DepositOrder> implements DepositOrderService {
|
|
@@ -34,23 +35,28 @@ public class DepositOrderServiceImpl extends ServiceImpl<DepositOrderMapper, Dep
|
|
|
OrderApi orderApi;
|
|
OrderApi orderApi;
|
|
|
|
|
|
|
|
final String DEPOSIT_ORDER_PRE = "DT";
|
|
final String DEPOSIT_ORDER_PRE = "DT";
|
|
|
|
|
+ private static final String DEPOSIT_TYPE_LOT = "拍品";
|
|
|
|
|
+ private static final String DEPOSIT_TYPE_AUCTION = "拍卖会";
|
|
|
|
|
+ private static final Integer DEPOSIT_STATUS_PAID = 1;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public int createDepositOrder(DepositOrderDTO depositOrderDTO) {
|
|
public int createDepositOrder(DepositOrderDTO depositOrderDTO) {
|
|
|
-
|
|
|
|
|
//查询拍品保证金配置
|
|
//查询拍品保证金配置
|
|
|
Long lotId = depositOrderDTO.getLotId();
|
|
Long lotId = depositOrderDTO.getLotId();
|
|
|
Lot lot = lotService.selectLotById(lotId);
|
|
Lot lot = lotService.selectLotById(lotId);
|
|
|
Long deposit = lot.getDeposit();
|
|
Long deposit = lot.getDeposit();
|
|
|
String name= lot.getName();
|
|
String name= lot.getName();
|
|
|
- String depositType="拍品";
|
|
|
|
|
|
|
+ String depositType=DEPOSIT_TYPE_LOT;
|
|
|
if (deposit ==null){
|
|
if (deposit ==null){
|
|
|
//如果没有拍品保证金配置,创建拍卖会保证金配置
|
|
//如果没有拍品保证金配置,创建拍卖会保证金配置
|
|
|
Auction auction = auctionService.selectAuctionById(lot.getAuctionId());
|
|
Auction auction = auctionService.selectAuctionById(lot.getAuctionId());
|
|
|
deposit=auction.getDeposit();
|
|
deposit=auction.getDeposit();
|
|
|
name=auction.getName();
|
|
name=auction.getName();
|
|
|
- depositType="拍卖会";
|
|
|
|
|
|
|
+ depositType=DEPOSIT_TYPE_AUCTION;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (hasPaidDeposit(depositOrderDTO.getUserId(), lot, depositType)) {
|
|
|
|
|
+ return 0;
|
|
|
}
|
|
}
|
|
|
depositOrderDTO.setAmount(deposit);
|
|
depositOrderDTO.setAmount(deposit);
|
|
|
depositOrderDTO.setAuctionId(lot.getAuctionId());
|
|
depositOrderDTO.setAuctionId(lot.getAuctionId());
|
|
@@ -68,6 +74,19 @@ public class DepositOrderServiceImpl extends ServiceImpl<DepositOrderMapper, Dep
|
|
|
depositOrder.setCreateTime(new Date());
|
|
depositOrder.setCreateTime(new Date());
|
|
|
return baseMapper.insert(depositOrder);
|
|
return baseMapper.insert(depositOrder);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private boolean hasPaidDeposit(Integer userId, Lot lot, String depositType) {
|
|
|
|
|
+ LambdaQueryWrapper<DepositOrder> queryWrapper = new LambdaQueryWrapper<DepositOrder>()
|
|
|
|
|
+ .eq(DepositOrder::getUserId, userId)
|
|
|
|
|
+ .eq(DepositOrder::getStatus, DEPOSIT_STATUS_PAID)
|
|
|
|
|
+ .eq(DepositOrder::getDepositType, depositType);
|
|
|
|
|
+ if (Objects.equals(DEPOSIT_TYPE_LOT, depositType)) {
|
|
|
|
|
+ queryWrapper.eq(DepositOrder::getLotId, lot.getId());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ queryWrapper.eq(DepositOrder::getAuctionId, lot.getAuctionId());
|
|
|
|
|
+ }
|
|
|
|
|
+ return baseMapper.selectCount(queryWrapper) > 0;
|
|
|
|
|
+ }
|
|
|
@Override
|
|
@Override
|
|
|
public void refundDepositOrder(String orderNo) {
|
|
public void refundDepositOrder(String orderNo) {
|
|
|
// OrderVO orderVO=new OrderVO();
|
|
// OrderVO orderVO=new OrderVO();
|