Commit 9440e870 by 章家宝

feat:轮询出价中途取消处理

1 parent 16644dfc
......@@ -136,13 +136,16 @@ public class AuctionChangeService extends AbstractAuctionService {
if (approveHistory.getApproveResult() == AuditState.AUDITED && auctionVehicle.inProgress()) {
// 处理撤销的逻辑
if (auctionVehicleChange.getChangeType() == AuctionBaseChange.ChangeType.CANCEL) {
Auction auction = auctionVehicle.getAuction();
// 中止车辆拍卖
if (auction.getAuctionType() == AuctionType.LIGHT && auction.getAuctionMode() == 2) {
lightAuctionPoollingBidService.cancelAucVeh(auctionVehicle);
}
Vehicle vehicle = auctionVehicle.getVehicle();
auctionVehicle.setAuctionState(AuctionVehicle.AuctionState.CANCELLED);
vehicle.setVehicleState(Vehicle.VehicleState.PRICED);
// 退回保证金
returnDepositsByAuctionVehicle(auctionVehicle, "参拍失败,解冻保证金");
Auction auction = auctionVehicle.getAuction();
auction.setVehicleCount(auction.getVehicleCount() - 1);
}
// 处理延期的逻辑
......
......@@ -306,10 +306,15 @@ public class AuctionService extends AbstractAuctionService {
vehicle.setVehicleState(Vehicle.VehicleState.PREVIEW);
}
case AUCTIONING -> {
if (auction.getAuctionMode() == 2 && auction.getAuctionType() == AuctionType.LIGHT) {
av.setAuctionState(AuctionVehicle.AuctionState.PREVIEW);
vehicle.setVehicleState(Vehicle.VehicleState.PREVIEW);
} else {
av.setAuctionState(AuctionVehicle.AuctionState.AUCTIONING);
vehicle.setVehicleState(Vehicle.VehicleState.AUCTIONING);
}
}
}
auctionVehicleDao.save(av);
if (auction.getAuctionType() == AuctionType.LIGHT && auction.getAuctionMode() == 2 && auction.getAuctionState() == Auction.AuctionState.AUCTIONING) {
lightAuctionPoollingBidService.addVehicle(av, auction);
......
......@@ -5,6 +5,7 @@ import com.glsx.usedcar.module.auction.dao.AuctionDao;
import com.glsx.usedcar.module.auction.dao.AuctionVehicleDao;
import com.glsx.usedcar.module.auction.entity.*;
import com.glsx.usedcar.module.auction.entity.Auction.AuctionType;
import com.glsx.usedcar.module.auction.entity.AuctionVehicle.AuctionState;
import com.glsx.usedcar.module.auction.entity.dto.LightPollingBidConfigDTO;
import com.glsx.usedcar.module.auction.entity.vo.LightAuctionPoolingBidNextAucVehVO;
import com.glsx.usedcar.module.auction.entity.vo.LightAuctionPoolingBidTimeAndPriceVO;
......@@ -562,4 +563,21 @@ public class LightAuctionPoollingBidService {
l.add(String.valueOf(av.getAucvehId()));
redisCacheUtil.setCacheWithExpire(String.format(AUCTION_ORDER_KEY, auction.getAuctionId()), StringUtils.join(l, ","), 24, TimeUnit.HOURS);
}
/**
* 取消车辆拍卖
*/
public void cancelAucVeh(AuctionVehicle auctionVehicle) {
log.info("取消车辆拍卖{} {}", auctionVehicle.getAucvehId(), auctionVehicle.getAuctionState());
if (auctionVehicle.getAuctionState() != AuctionState.AUCTIONING) {
return;
}
Auction auction = auctionVehicle.getAuction();
LightPollingBidConfigDTO lightPollingBidConfigDTO = LightPollingBidConfigDTO.fromJson(auction.getExtraJson());
int bidAucVehDuration = lightPollingBidConfigDTO.getBidAucVehDuration();
long curr = System.currentTimeMillis();
long nextAuctionVehicleStartTimeMillis = curr + bidAucVehDuration * 1000L;
redisCacheUtil.setCacheWithExpire(String.format(NEXT_AUCTION_VEHICLE_START_TIME_KEY, auction.getAuctionId()), nextAuctionVehicleStartTimeMillis, 24, TimeUnit.HOURS);
redisCacheUtil.setCacheWithExpire(String.format(END_TIME_KEY, auctionVehicle.getAucvehId()), curr, 24, TimeUnit.HOURS);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!