랜드소유권변경 예약 취소 처리
This commit is contained in:
@@ -32,12 +32,12 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static com.caliverse.admin.global.common.utils.CommonUtils.convertIsoByDatetime;
|
||||
import static com.caliverse.admin.global.common.utils.DateUtils.stringToDateTime;
|
||||
import static com.caliverse.admin.global.common.utils.DateUtils.stringISOToLocalDateTime;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -93,14 +93,34 @@ public class LandService {
|
||||
|
||||
return result;
|
||||
})
|
||||
.map(data -> buildLandInfo(data, buildingData, auctions))
|
||||
.map(data -> buildLandInfo(data, buildingData, auctions)).filter(Objects::nonNull)
|
||||
.filter(info -> {
|
||||
boolean result = true;
|
||||
|
||||
if (!status.equals("ALL")) {
|
||||
result = info.getStatus().contains(status);
|
||||
}
|
||||
|
||||
if (!category.equals("ALL")) {
|
||||
result = info.getCategory().contains(category);
|
||||
}
|
||||
|
||||
String createDate = info.getOwnerUserCreateDate();
|
||||
if (!startDt.isEmpty() && !endDt.isEmpty()) {
|
||||
if (createDate.isEmpty()) {
|
||||
result = false;
|
||||
} else {
|
||||
LocalDateTime start_dt = stringISOToLocalDateTime(startDt);
|
||||
LocalDateTime end_dt = stringISOToLocalDateTime(endDt);
|
||||
LocalDateTime date = DateUtils.stringToLocalDateTime(createDate);
|
||||
result = (date.isEqual(start_dt) || date.isAfter(start_dt)) &&
|
||||
(date.isEqual(end_dt) || date.isBefore(end_dt));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
})
|
||||
.sorted(orderBy.equals("DESC") ?
|
||||
.sorted(orderBy.equals("ASC") ?
|
||||
Comparator.comparing(LandInfo::getLandId).reversed() :
|
||||
Comparator.comparing(LandInfo::getLandId))
|
||||
.toList();
|
||||
@@ -108,19 +128,19 @@ public class LandService {
|
||||
// 페이징 처리
|
||||
int totalItems = list.size();
|
||||
int totalPages = (int) Math.ceil((double) totalItems / size);
|
||||
page = (totalItems > 0 && page >= totalPages) ? totalPages - 1 : page;
|
||||
page = (totalItems > 0 && page > totalPages) ? totalPages : page;
|
||||
|
||||
List<LandInfo> pagedList = (totalItems == 0) ?
|
||||
new ArrayList<>() :
|
||||
list.subList(page * size, Math.min((page * size) + size, totalItems));
|
||||
list.subList((page - 1) * size, Math.min((page - 1) * size + size, totalItems));
|
||||
|
||||
return LandResponse.builder()
|
||||
.resultData(LandResponse.ResultData.builder()
|
||||
.landInfoList(pagedList)
|
||||
.total(pagedList.size())
|
||||
.totalAll(totalItems)
|
||||
.pageNo(requestParam.get("page_no")!=null?
|
||||
Integer.parseInt(requestParam.get("page_no")):1)
|
||||
.pageNo(requestParam.get("page_no") != null ?
|
||||
Integer.parseInt(requestParam.get("page_no")) : 1)
|
||||
.build())
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
@@ -138,36 +158,52 @@ public class LandService {
|
||||
String ownerDate = "";
|
||||
double ownerPrice = 0;
|
||||
String category = "";
|
||||
String status = "";
|
||||
String status = LandInfo.LAND_STATUS.NONE.toString();
|
||||
|
||||
List<LandOwnerChange> ownerChanges = new ArrayList<>();
|
||||
|
||||
if(editor.equals(CommonConstants.USER)){
|
||||
LandAttrib land = dynamodbLandService.getLandInfo(landId);
|
||||
//랜드 존재
|
||||
if(land != null){
|
||||
ownerGuid = land.getOwnerUserGuid();
|
||||
ownerName = dynamodbUserService.getGuidByName(ownerGuid);
|
||||
|
||||
int auctionNumber = dynamodbLandAuctionService.getLandAuctionNumber(landId);
|
||||
// 경매
|
||||
if(auctionNumber > 0){
|
||||
LandAuction auction = auctions.stream()
|
||||
.filter(row -> row.getLandId().equals(landId) && row.getAuctionSeq().equals(auctionNumber))
|
||||
.findFirst().orElse(null);
|
||||
if(auction == null){
|
||||
log.error("getLandInfo.buildLandInfo auction info error landId: {}, auctionNumber: {}", landId, auctionNumber);
|
||||
}
|
||||
LandAuction.AUCTION_STATUS auctionStatus = auction.getStatus();
|
||||
if(auctionStatus.equals(LandAuction.AUCTION_STATUS.FAIL) || auctionStatus.equals(LandAuction.AUCTION_STATUS.CANCEL)){
|
||||
status = "";
|
||||
if(!ownerGuid.isEmpty()){
|
||||
ownerName = dynamodbUserService.getGuidByName(ownerGuid);
|
||||
int auctionNumber = dynamodbLandAuctionService.getLandAuctionNumber(landId);
|
||||
// 경매
|
||||
if(auctionNumber > 0){
|
||||
LandAuction auction = auctions.stream()
|
||||
.filter(row -> row.getLandId().equals(landId) && row.getAuctionSeq().equals(auctionNumber))
|
||||
.findFirst().orElse(null);
|
||||
if(auction == null){
|
||||
log.warn("getLandInfo.buildLandInfo auction info error landId: {}, auctionNumber: {}", landId, auctionNumber);
|
||||
LandAuctionHighestBidUserAttrib bidUser = dynamodbLandAuctionService.getLandAuctionHighestUser(landId, auctionNumber);
|
||||
LandAuctionRegistryAttrib auctionRegistry = dynamodbLandAuctionService.getLandAuctionRegistry(landId, auctionNumber);
|
||||
if(bidUser != null && auctionRegistry != null){
|
||||
status = LandInfo.LAND_STATUS.AUCTION_END.toString();
|
||||
ownerPrice = bidUser.getHighestBidPrice();
|
||||
ownerDate = convertIsoByDatetime(auctionRegistry.getAuctionEndTime());
|
||||
}
|
||||
}else{
|
||||
LandAuction.AUCTION_STATUS auctionStatus = auction.getStatus();
|
||||
if(auctionStatus.equals(LandAuction.AUCTION_STATUS.FAIL) || auctionStatus.equals(LandAuction.AUCTION_STATUS.CANCEL)){
|
||||
status = "";
|
||||
}else{
|
||||
status = auctionStatus.toString();
|
||||
if(auctionStatus.equals(LandAuction.AUCTION_STATUS.AUCTION_END)){
|
||||
ownerPrice = auction.getClosePrice();
|
||||
ownerDate = stringToDateTime(auction.getCloseEndDt());
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
status = auctionStatus.toString();
|
||||
String parsedDate = dynamodbLandService.getLandOwnerCreateDate(ownerGuid, landId);
|
||||
ownerDate = parsedDate.isEmpty() ? "" : convertIsoByDatetime(parsedDate);
|
||||
status = LandInfo.LAND_STATUS.OWNED.toString();
|
||||
}
|
||||
ownerPrice = auction.getClosePrice();
|
||||
ownerDate = stringToDateTime(auction.getCloseEndDt());
|
||||
}else{
|
||||
String parsedDate = dynamodbLandService.getLandOwnerCreateDate(ownerGuid, landId);
|
||||
ownerDate = convertIsoByDatetime(parsedDate);
|
||||
}
|
||||
}else{
|
||||
ownerChanges = landMapper.getLandOwnerChangeInfo(landId);
|
||||
}
|
||||
}else{
|
||||
ownerName = CommonConstants.CALIVERSE_NAME;
|
||||
@@ -208,6 +244,7 @@ public class LandService {
|
||||
.ownerUserNickname(ownerName)
|
||||
.ownerUserCreateDate(ownerDate)
|
||||
.ownerPrice(String.valueOf(ownerPrice))
|
||||
.ownerChanges(ownerChanges)
|
||||
.build();
|
||||
}catch(Exception e){
|
||||
log.error("buildLandInfo", e);
|
||||
@@ -516,6 +553,9 @@ public class LandService {
|
||||
landRequest.setUpdateBy(CommonUtils.getAdmin().getId());
|
||||
landRequest.setUpdateDt(LocalDateTime.now());
|
||||
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("id", String.valueOf(id));
|
||||
|
||||
LandOwnerChange before_info = landMapper.getLandOwnerChangeDetail(id);
|
||||
|
||||
int result = landMapper.updateLandOwnerChange(landRequest);
|
||||
@@ -603,10 +643,50 @@ public class LandService {
|
||||
.build();
|
||||
}
|
||||
|
||||
@Transactional(transactionManager = "transactionManager")
|
||||
public LandResponse deleteLandOwnerChanges(LandRequest landRequest){
|
||||
Long id = landRequest.getId();
|
||||
LandOwnerChange info = landMapper.getLandOwnerChangeDetail(id);
|
||||
|
||||
//예약상태가 아니면 취소할 수 없다
|
||||
if(!info.getStatus().equals(LandOwnerChange.CHANGE_STATUS.WAIT)){
|
||||
return LandResponse.builder()
|
||||
.status(CommonCode.ERROR.getHttpStatus())
|
||||
.result(ErrorCode.ERROR_LAND_OWNER_CHANGES_RESERVATION.toString())
|
||||
.build();
|
||||
}
|
||||
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("id", id);
|
||||
map.put("updateBy", CommonUtils.getAdmin().getId());
|
||||
int result = landMapper.deleteLandOwnerChanges(map);
|
||||
log.info("LandOwnerChanges Delete Complete: {}", landRequest);
|
||||
|
||||
mysqlHistoryLogService.deleteHistoryLog(
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_DELETE,
|
||||
MysqlConstants.TABLE_NAME_LAND_OWNER_CHANGE,
|
||||
HISTORYTYPE.LAND_OWNER_CHANGE_DELETE.name(),
|
||||
info,
|
||||
CommonUtils.getAdmin().getEmail(),
|
||||
CommonUtils.getClientIp()
|
||||
);
|
||||
|
||||
return LandResponse.builder()
|
||||
.resultData(LandResponse.ResultData.builder()
|
||||
.build())
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.build();
|
||||
}
|
||||
|
||||
public List<LandAuction> getScheduleLandAuctionList(){
|
||||
return landMapper.getScheduleLandAuctionList();
|
||||
}
|
||||
|
||||
public List<LandOwnerChange> getScheduleLandOwnerChangesList(){
|
||||
return landMapper.getScheduleLandOwnedChangeList();
|
||||
}
|
||||
|
||||
public LandAuctionRegistryAttrib getLandAuctionRegistryAttrib(Integer land_id, Integer auction_seq){
|
||||
return dynamodbLandAuctionService.getLandAuctionRegistry(land_id, auction_seq);
|
||||
}
|
||||
@@ -628,7 +708,7 @@ public class LandService {
|
||||
@Transactional(transactionManager = "transactionManager")
|
||||
public void updateLandOwnedChangeStatus(Map<String,Object> map){
|
||||
try{
|
||||
landMapper.updateStatusLandAuction(map);
|
||||
landMapper.updateStatusLandOwnedChange(map);
|
||||
log.info("updateLandOwnedChangeStatus LandOwned status changed: {}", map.get("status"));
|
||||
}catch(Exception e){
|
||||
log.error("updateLandOwnedChangeStatus LandOwned Update Fail map: {}", map);
|
||||
|
||||
Reference in New Issue
Block a user