[+] CardMaker 1.39 support (#79)

This commit is contained in:
2024-11-04 19:18:56 +08:00
committed by GitHub
parent 996632ac73
commit bf972681d5
11 changed files with 531 additions and 20 deletions

View File

@@ -155,7 +155,7 @@ class Maimai2ServletController(
"userId" to userId,
"userName" to it.userName,
"rating" to it.playerRating,
"lastDataVersion" to "1.20.00",
"lastDataVersion" to it.lastDataVersion,
"isLogin" to false,
"isExistSellingCard" to false
)

View File

@@ -15,17 +15,20 @@ import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ThreadLocalRandom;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* @author samnyan (privateamusement@protonmail.com)
*/
@Component("Maimai2UpsertUserPrintHandler")
@AllArgsConstructor
public class UpsertUserPrintHandler implements BaseHandler {
private static final Logger logger = LoggerFactory.getLogger(UpsertUserPrintHandler.class);
@@ -35,6 +38,21 @@ public class UpsertUserPrintHandler implements BaseHandler {
private final Mai2UserPrintDetailRepo userPrintDetailRepository;
private final Mai2UserDataRepo userDataRepository;
private long expirationTime;
public UpsertUserPrintHandler(BasicMapper mapper,
@Value("${game.cardmaker.card.expiration:15}") long expirationTime,
Mai2UserCardRepo userCardRepository,
Mai2UserPrintDetailRepo userPrintDetailRepository,
Mai2UserDataRepo userDataRepository
) {
this.mapper = mapper;
this.expirationTime = expirationTime;
this.userCardRepository = userCardRepository;
this.userPrintDetailRepository = userPrintDetailRepository;
this.userDataRepository = userDataRepository;
}
@Override
public String handle(Map<String, Object> request) throws JsonProcessingException {
long userId = ((Number) request.get("userId")).longValue();
@@ -54,12 +72,19 @@ public class UpsertUserPrintHandler implements BaseHandler {
Mai2UserPrintDetail userPrintDetail = upsertUserPrint.getUserPrintDetail();
Mai2UserCard newUserCard = userPrintDetail.getUserCard();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
String currentDateTime = LocalDateTime.now().format(formatter);
String expirationDateTime = LocalDateTime.now().plusDays(expirationTime).format(formatter);
String randomSerialId =
String.format("%010d", ThreadLocalRandom.current().nextLong(0L, 9999999999L)) +
String.format("%010d", ThreadLocalRandom.current().nextLong(0L, 9999999999L));
newUserCard.setUser(userData);
userPrintDetail.setUser(userData);
newUserCard.setStartDate("2019-01-01 00:00:00.000000");
newUserCard.setEndDate("2029-01-01 00:00:00.000000");
userPrintDetail.setSerialId("FAKECARDIMAG12345678");
newUserCard.setStartDate(currentDateTime);
newUserCard.setEndDate(expirationDateTime);
userPrintDetail.setSerialId(randomSerialId);
Optional<Mai2UserCard> userCardOptional = userCardRepository.findByUserAndCardId(newUserCard.getUser(), newUserCard.getCardId());
if (userCardOptional.isPresent()) {
@@ -73,9 +98,9 @@ public class UpsertUserPrintHandler implements BaseHandler {
Map<String, Object> resultMap = new LinkedHashMap<>();
resultMap.put("returnCode", 1);
resultMap.put("orderId", 0);
resultMap.put("serialId", "FAKECARDIMAG12345678");
resultMap.put("startDate", "2019-01-01 00:00:00.000000");
resultMap.put("endDate", "2029-01-01 00:00:00.000000");
resultMap.put("serialId", randomSerialId);
resultMap.put("startDate", currentDateTime);
resultMap.put("endDate", expirationDateTime);
return mapper.write(resultMap);
}

View File

@@ -37,8 +37,8 @@ class Mai2GameCharge : BaseEntity() {
@Table(name = "maimai2_game_selling_card")
class Mai2GameSellingCard : BaseEntity() {
var cardId = 0L
var startDate: LocalDateTime? = null
var endDate: LocalDateTime? = null
var noticeStartDate: LocalDateTime? = null
var noticeEndDate: LocalDateTime? = null
var startDate: String? = null
var endDate: String? = null
var noticeStartDate: String? = null
var noticeEndDate: String? = null
}