랜드소유권변경 예약 취소 처리
This commit is contained in:
@@ -79,4 +79,10 @@ public class LandController {
|
||||
|
||||
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();
|
||||
LandAuction getLandAuctionDetail(Long id);
|
||||
LandOwnerChange getLandOwnerChangeDetail(Long id);
|
||||
List<LandOwnerChange> getLandOwnerChangeInfo(int landId);
|
||||
|
||||
List<Message> getMessage(Long id);
|
||||
|
||||
@@ -33,8 +34,11 @@ public interface LandMapper {
|
||||
int deleteMessage(Map map);
|
||||
|
||||
int deleteLandAuction(Map map);
|
||||
int deleteLandOwnerChanges(Map map);
|
||||
|
||||
int updateStatusLandAuction(Map map);
|
||||
int updateStatusLandOwnedChange(Map map);
|
||||
|
||||
List<LandAuction> getScheduleLandAuctionList();
|
||||
List<LandOwnerChange> getScheduleLandOwnedChangeList();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,8 @@ public enum HISTORYTYPE {
|
||||
BATTLE_EVENT_UPDATE("전투시스템 이벤트 수정"),
|
||||
BATTLE_EVENT_DELETE("전투시스템 이벤트 삭제"),
|
||||
LAND_OWNER_CHANGE_ADD("랜드 소유권 변경 등록"),
|
||||
LAND_OWNER_CHANGE_UPDATE("랜드 소유권 변경 수정")
|
||||
LAND_OWNER_CHANGE_UPDATE("랜드 소유권 변경 수정"),
|
||||
LAND_OWNER_CHANGE_DELETE("랜드 소유권 변경 예약 취소")
|
||||
;
|
||||
private String historyType;
|
||||
HISTORYTYPE(String type) {
|
||||
|
||||
@@ -8,6 +8,8 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@@ -49,6 +51,8 @@ public class LandInfo {
|
||||
private String status;
|
||||
private String isUpdate;
|
||||
private boolean isOwned;
|
||||
@JsonProperty("owner_changes")
|
||||
private List<LandOwnerChange> ownerChanges;
|
||||
|
||||
public enum LAND_STATUS {
|
||||
NONE,
|
||||
|
||||
@@ -22,12 +22,18 @@ public class LandOwnerChange {
|
||||
private Integer landId;
|
||||
@JsonProperty("land_name")
|
||||
private String landName;
|
||||
@JsonProperty("building_id")
|
||||
private Integer buildingId;
|
||||
@JsonProperty("building_name")
|
||||
private String buildingName;
|
||||
@JsonProperty("user_guid")
|
||||
private String userGuid;
|
||||
@JsonProperty("user_name")
|
||||
private String userName;
|
||||
@JsonProperty("reservation_dt")
|
||||
private LocalDateTime reservationDt;
|
||||
@JsonProperty("is_reserve")
|
||||
private LocalDateTime isReserve;
|
||||
private boolean isReserve;
|
||||
private CHANGE_STATUS status;
|
||||
|
||||
private boolean deleted;
|
||||
@@ -45,6 +51,7 @@ public class LandOwnerChange {
|
||||
WAIT,
|
||||
FINISH,
|
||||
RUNNING,
|
||||
CANCEL,
|
||||
FAIL
|
||||
;
|
||||
}
|
||||
|
||||
@@ -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,15 +158,17 @@ 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();
|
||||
if(!ownerGuid.isEmpty()){
|
||||
ownerName = dynamodbUserService.getGuidByName(ownerGuid);
|
||||
|
||||
int auctionNumber = dynamodbLandAuctionService.getLandAuctionNumber(landId);
|
||||
// 경매
|
||||
if(auctionNumber > 0){
|
||||
@@ -154,21 +176,35 @@ public class LandService {
|
||||
.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);
|
||||
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{
|
||||
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{
|
||||
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