랜드소유권변경 예약 취소 처리
This commit is contained in:
@@ -79,4 +79,10 @@ public class LandController {
|
|||||||
|
|
||||||
return ResponseEntity.ok().body(landService.deleteLandAuction(landRequest));
|
return ResponseEntity.ok().body(landService.deleteLandAuction(landRequest));
|
||||||
}
|
}
|
||||||
|
@DeleteMapping("/change/delete")
|
||||||
|
public ResponseEntity<LandResponse> deleteLandOwnerChanges(
|
||||||
|
@RequestBody LandRequest landRequest){
|
||||||
|
|
||||||
|
return ResponseEntity.ok().body(landService.deleteLandOwnerChanges(landRequest));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public interface LandMapper {
|
|||||||
int getTotal();
|
int getTotal();
|
||||||
LandAuction getLandAuctionDetail(Long id);
|
LandAuction getLandAuctionDetail(Long id);
|
||||||
LandOwnerChange getLandOwnerChangeDetail(Long id);
|
LandOwnerChange getLandOwnerChangeDetail(Long id);
|
||||||
|
List<LandOwnerChange> getLandOwnerChangeInfo(int landId);
|
||||||
|
|
||||||
List<Message> getMessage(Long id);
|
List<Message> getMessage(Long id);
|
||||||
|
|
||||||
@@ -33,8 +34,11 @@ public interface LandMapper {
|
|||||||
int deleteMessage(Map map);
|
int deleteMessage(Map map);
|
||||||
|
|
||||||
int deleteLandAuction(Map map);
|
int deleteLandAuction(Map map);
|
||||||
|
int deleteLandOwnerChanges(Map map);
|
||||||
|
|
||||||
int updateStatusLandAuction(Map map);
|
int updateStatusLandAuction(Map map);
|
||||||
|
int updateStatusLandOwnedChange(Map map);
|
||||||
|
|
||||||
List<LandAuction> getScheduleLandAuctionList();
|
List<LandAuction> getScheduleLandAuctionList();
|
||||||
|
List<LandOwnerChange> getScheduleLandOwnedChangeList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ public enum HISTORYTYPE {
|
|||||||
BATTLE_EVENT_UPDATE("전투시스템 이벤트 수정"),
|
BATTLE_EVENT_UPDATE("전투시스템 이벤트 수정"),
|
||||||
BATTLE_EVENT_DELETE("전투시스템 이벤트 삭제"),
|
BATTLE_EVENT_DELETE("전투시스템 이벤트 삭제"),
|
||||||
LAND_OWNER_CHANGE_ADD("랜드 소유권 변경 등록"),
|
LAND_OWNER_CHANGE_ADD("랜드 소유권 변경 등록"),
|
||||||
LAND_OWNER_CHANGE_UPDATE("랜드 소유권 변경 수정")
|
LAND_OWNER_CHANGE_UPDATE("랜드 소유권 변경 수정"),
|
||||||
|
LAND_OWNER_CHANGE_DELETE("랜드 소유권 변경 예약 취소")
|
||||||
;
|
;
|
||||||
private String historyType;
|
private String historyType;
|
||||||
HISTORYTYPE(String type) {
|
HISTORYTYPE(String type) {
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import lombok.Data;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@@ -49,6 +51,8 @@ public class LandInfo {
|
|||||||
private String status;
|
private String status;
|
||||||
private String isUpdate;
|
private String isUpdate;
|
||||||
private boolean isOwned;
|
private boolean isOwned;
|
||||||
|
@JsonProperty("owner_changes")
|
||||||
|
private List<LandOwnerChange> ownerChanges;
|
||||||
|
|
||||||
public enum LAND_STATUS {
|
public enum LAND_STATUS {
|
||||||
NONE,
|
NONE,
|
||||||
|
|||||||
@@ -22,12 +22,18 @@ public class LandOwnerChange {
|
|||||||
private Integer landId;
|
private Integer landId;
|
||||||
@JsonProperty("land_name")
|
@JsonProperty("land_name")
|
||||||
private String landName;
|
private String landName;
|
||||||
|
@JsonProperty("building_id")
|
||||||
|
private Integer buildingId;
|
||||||
|
@JsonProperty("building_name")
|
||||||
|
private String buildingName;
|
||||||
@JsonProperty("user_guid")
|
@JsonProperty("user_guid")
|
||||||
private String userGuid;
|
private String userGuid;
|
||||||
|
@JsonProperty("user_name")
|
||||||
|
private String userName;
|
||||||
@JsonProperty("reservation_dt")
|
@JsonProperty("reservation_dt")
|
||||||
private LocalDateTime reservationDt;
|
private LocalDateTime reservationDt;
|
||||||
@JsonProperty("is_reserve")
|
@JsonProperty("is_reserve")
|
||||||
private LocalDateTime isReserve;
|
private boolean isReserve;
|
||||||
private CHANGE_STATUS status;
|
private CHANGE_STATUS status;
|
||||||
|
|
||||||
private boolean deleted;
|
private boolean deleted;
|
||||||
@@ -45,6 +51,7 @@ public class LandOwnerChange {
|
|||||||
WAIT,
|
WAIT,
|
||||||
FINISH,
|
FINISH,
|
||||||
RUNNING,
|
RUNNING,
|
||||||
|
CANCEL,
|
||||||
FAIL
|
FAIL
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeParseException;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import static com.caliverse.admin.global.common.utils.CommonUtils.convertIsoByDatetime;
|
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.stringToDateTime;
|
||||||
|
import static com.caliverse.admin.global.common.utils.DateUtils.stringISOToLocalDateTime;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@@ -93,14 +93,34 @@ public class LandService {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
})
|
})
|
||||||
.map(data -> buildLandInfo(data, buildingData, auctions))
|
.map(data -> buildLandInfo(data, buildingData, auctions)).filter(Objects::nonNull)
|
||||||
.filter(info -> {
|
.filter(info -> {
|
||||||
boolean result = true;
|
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;
|
return result;
|
||||||
})
|
})
|
||||||
.sorted(orderBy.equals("DESC") ?
|
.sorted(orderBy.equals("ASC") ?
|
||||||
Comparator.comparing(LandInfo::getLandId).reversed() :
|
Comparator.comparing(LandInfo::getLandId).reversed() :
|
||||||
Comparator.comparing(LandInfo::getLandId))
|
Comparator.comparing(LandInfo::getLandId))
|
||||||
.toList();
|
.toList();
|
||||||
@@ -108,11 +128,11 @@ public class LandService {
|
|||||||
// 페이징 처리
|
// 페이징 처리
|
||||||
int totalItems = list.size();
|
int totalItems = list.size();
|
||||||
int totalPages = (int) Math.ceil((double) totalItems / 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) ?
|
List<LandInfo> pagedList = (totalItems == 0) ?
|
||||||
new ArrayList<>() :
|
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()
|
return LandResponse.builder()
|
||||||
.resultData(LandResponse.ResultData.builder()
|
.resultData(LandResponse.ResultData.builder()
|
||||||
@@ -138,15 +158,17 @@ public class LandService {
|
|||||||
String ownerDate = "";
|
String ownerDate = "";
|
||||||
double ownerPrice = 0;
|
double ownerPrice = 0;
|
||||||
String category = "";
|
String category = "";
|
||||||
String status = "";
|
String status = LandInfo.LAND_STATUS.NONE.toString();
|
||||||
|
|
||||||
|
List<LandOwnerChange> ownerChanges = new ArrayList<>();
|
||||||
|
|
||||||
if(editor.equals(CommonConstants.USER)){
|
if(editor.equals(CommonConstants.USER)){
|
||||||
LandAttrib land = dynamodbLandService.getLandInfo(landId);
|
LandAttrib land = dynamodbLandService.getLandInfo(landId);
|
||||||
//랜드 존재
|
//랜드 존재
|
||||||
if(land != null){
|
if(land != null){
|
||||||
ownerGuid = land.getOwnerUserGuid();
|
ownerGuid = land.getOwnerUserGuid();
|
||||||
|
if(!ownerGuid.isEmpty()){
|
||||||
ownerName = dynamodbUserService.getGuidByName(ownerGuid);
|
ownerName = dynamodbUserService.getGuidByName(ownerGuid);
|
||||||
|
|
||||||
int auctionNumber = dynamodbLandAuctionService.getLandAuctionNumber(landId);
|
int auctionNumber = dynamodbLandAuctionService.getLandAuctionNumber(landId);
|
||||||
// 경매
|
// 경매
|
||||||
if(auctionNumber > 0){
|
if(auctionNumber > 0){
|
||||||
@@ -154,21 +176,35 @@ public class LandService {
|
|||||||
.filter(row -> row.getLandId().equals(landId) && row.getAuctionSeq().equals(auctionNumber))
|
.filter(row -> row.getLandId().equals(landId) && row.getAuctionSeq().equals(auctionNumber))
|
||||||
.findFirst().orElse(null);
|
.findFirst().orElse(null);
|
||||||
if(auction == null){
|
if(auction == null){
|
||||||
log.error("getLandInfo.buildLandInfo auction info error landId: {}, auctionNumber: {}", landId, auctionNumber);
|
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();
|
LandAuction.AUCTION_STATUS auctionStatus = auction.getStatus();
|
||||||
if(auctionStatus.equals(LandAuction.AUCTION_STATUS.FAIL) || auctionStatus.equals(LandAuction.AUCTION_STATUS.CANCEL)){
|
if(auctionStatus.equals(LandAuction.AUCTION_STATUS.FAIL) || auctionStatus.equals(LandAuction.AUCTION_STATUS.CANCEL)){
|
||||||
status = "";
|
status = "";
|
||||||
}else{
|
}else{
|
||||||
status = auctionStatus.toString();
|
status = auctionStatus.toString();
|
||||||
}
|
if(auctionStatus.equals(LandAuction.AUCTION_STATUS.AUCTION_END)){
|
||||||
ownerPrice = auction.getClosePrice();
|
ownerPrice = auction.getClosePrice();
|
||||||
ownerDate = stringToDateTime(auction.getCloseEndDt());
|
ownerDate = stringToDateTime(auction.getCloseEndDt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
String parsedDate = dynamodbLandService.getLandOwnerCreateDate(ownerGuid, landId);
|
String parsedDate = dynamodbLandService.getLandOwnerCreateDate(ownerGuid, landId);
|
||||||
ownerDate = convertIsoByDatetime(parsedDate);
|
ownerDate = parsedDate.isEmpty() ? "" : convertIsoByDatetime(parsedDate);
|
||||||
|
status = LandInfo.LAND_STATUS.OWNED.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
ownerChanges = landMapper.getLandOwnerChangeInfo(landId);
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
ownerName = CommonConstants.CALIVERSE_NAME;
|
ownerName = CommonConstants.CALIVERSE_NAME;
|
||||||
}
|
}
|
||||||
@@ -208,6 +244,7 @@ public class LandService {
|
|||||||
.ownerUserNickname(ownerName)
|
.ownerUserNickname(ownerName)
|
||||||
.ownerUserCreateDate(ownerDate)
|
.ownerUserCreateDate(ownerDate)
|
||||||
.ownerPrice(String.valueOf(ownerPrice))
|
.ownerPrice(String.valueOf(ownerPrice))
|
||||||
|
.ownerChanges(ownerChanges)
|
||||||
.build();
|
.build();
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
log.error("buildLandInfo", e);
|
log.error("buildLandInfo", e);
|
||||||
@@ -516,6 +553,9 @@ public class LandService {
|
|||||||
landRequest.setUpdateBy(CommonUtils.getAdmin().getId());
|
landRequest.setUpdateBy(CommonUtils.getAdmin().getId());
|
||||||
landRequest.setUpdateDt(LocalDateTime.now());
|
landRequest.setUpdateDt(LocalDateTime.now());
|
||||||
|
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
map.put("id", String.valueOf(id));
|
||||||
|
|
||||||
LandOwnerChange before_info = landMapper.getLandOwnerChangeDetail(id);
|
LandOwnerChange before_info = landMapper.getLandOwnerChangeDetail(id);
|
||||||
|
|
||||||
int result = landMapper.updateLandOwnerChange(landRequest);
|
int result = landMapper.updateLandOwnerChange(landRequest);
|
||||||
@@ -603,10 +643,50 @@ public class LandService {
|
|||||||
.build();
|
.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(){
|
public List<LandAuction> getScheduleLandAuctionList(){
|
||||||
return landMapper.getScheduleLandAuctionList();
|
return landMapper.getScheduleLandAuctionList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<LandOwnerChange> getScheduleLandOwnerChangesList(){
|
||||||
|
return landMapper.getScheduleLandOwnedChangeList();
|
||||||
|
}
|
||||||
|
|
||||||
public LandAuctionRegistryAttrib getLandAuctionRegistryAttrib(Integer land_id, Integer auction_seq){
|
public LandAuctionRegistryAttrib getLandAuctionRegistryAttrib(Integer land_id, Integer auction_seq){
|
||||||
return dynamodbLandAuctionService.getLandAuctionRegistry(land_id, auction_seq);
|
return dynamodbLandAuctionService.getLandAuctionRegistry(land_id, auction_seq);
|
||||||
}
|
}
|
||||||
@@ -628,7 +708,7 @@ public class LandService {
|
|||||||
@Transactional(transactionManager = "transactionManager")
|
@Transactional(transactionManager = "transactionManager")
|
||||||
public void updateLandOwnedChangeStatus(Map<String,Object> map){
|
public void updateLandOwnedChangeStatus(Map<String,Object> map){
|
||||||
try{
|
try{
|
||||||
landMapper.updateStatusLandAuction(map);
|
landMapper.updateStatusLandOwnedChange(map);
|
||||||
log.info("updateLandOwnedChangeStatus LandOwned status changed: {}", map.get("status"));
|
log.info("updateLandOwnedChangeStatus LandOwned status changed: {}", map.get("status"));
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
log.error("updateLandOwnedChangeStatus LandOwned Update Fail map: {}", map);
|
log.error("updateLandOwnedChangeStatus LandOwned Update Fail map: {}", map);
|
||||||
|
|||||||
Reference in New Issue
Block a user