|
|
@@ -20,6 +20,9 @@ import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
import org.springframework.data.annotation.Transient;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
@@ -69,28 +72,42 @@ public class DomainOrderService {
|
|
|
public DomainOrder create(Long userId, String domain, BigDecimal price, Long year) {
|
|
|
List<DomainOrder> notPaidOrders = domainOrderRepo.findAllByUserIdAndOrderStatus(userId, OrderStatus.NOT_PAID);
|
|
|
Long superUserId = Long.valueOf(sysConfigService.getString("domain_superUserId"));
|
|
|
+ if (notPaidOrders.size() > 0) {
|
|
|
+ throw new BusinessException("已存在未支付订单,不可继续下单");
|
|
|
+ }
|
|
|
+ if (domain.contains(".uni")) {
|
|
|
+ throw new BusinessException("域名后缀不符合规定.");
|
|
|
+ }
|
|
|
if (!superUserId.equals(SecurityUtils.getAuthenticatedUser().getId())) {
|
|
|
if (isContainChinese(domain)) {
|
|
|
throw new BusinessException("禁止注册中文域名");
|
|
|
}
|
|
|
- if (notPaidOrders.size() > 0) {
|
|
|
- throw new BusinessException("已存在未支付订单,不可继续下单");
|
|
|
- }
|
|
|
if (domain.length() < 9) {
|
|
|
throw new BusinessException("四位及以下域名只能官方创建。");
|
|
|
}
|
|
|
}
|
|
|
- Map<String, Object> checkResult = check(domain);
|
|
|
+ String realName;
|
|
|
+ int dotIndex = domain.indexOf(".");
|
|
|
+ realName = domain.substring(0, dotIndex);
|
|
|
+ Map<String, Object> checkResult = check(realName);
|
|
|
if (!(Boolean) checkResult.get("result")) {
|
|
|
throw new BusinessException(checkResult.get("reason").toString());
|
|
|
}
|
|
|
+ BigDecimal singlePrice = sysConfigService.getBigDecimal("domain_price");
|
|
|
+ if (singlePrice.multiply(BigDecimal.valueOf(year)).compareTo(price) != 0) {
|
|
|
+ throw new BusinessException("价格不符");
|
|
|
+ }
|
|
|
+// LocalDateTime startTime = LocalDateTime.of(2023, 2, 10, 17, 0, 0);
|
|
|
+// if (LocalDateTime.now().isBefore(startTime)) {
|
|
|
+// throw new BusinessException("时间不符");
|
|
|
+// }
|
|
|
// if (price.compareTo(BigDecimal.valueOf(40L)) != 0) {
|
|
|
// throw new BusinessException("订单价格与配置不符,请重新下单.");
|
|
|
// }
|
|
|
User user = userRepo.findById(userId).orElseThrow(new BusinessException("未找到用户"));
|
|
|
if (domain.contains(".")) {
|
|
|
- int dotIndex = domain.indexOf(".");
|
|
|
- domain = domain.substring(0, dotIndex);
|
|
|
+ int dotIndex1 = domain.indexOf(".");
|
|
|
+ domain = domain.substring(0, dotIndex1);
|
|
|
}
|
|
|
|
|
|
DomainOrder domainOrder = new DomainOrder();
|
|
|
@@ -108,11 +125,18 @@ public class DomainOrderService {
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> check(String domain) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
Long superUserId = Long.valueOf(sysConfigService.getString("domain_superUserId"));
|
|
|
- String visibleDomain = domain + ".nft";
|
|
|
+ String visibleDomain = domain;
|
|
|
+ if (domain.contains(".uni")) {
|
|
|
+ result.put("result", false);
|
|
|
+ result.put("reason", "禁止使用.uni");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if (!domain.contains(".nft")) {
|
|
|
+ visibleDomain = domain + ".nft";
|
|
|
+ }
|
|
|
List<String> keywords = Arrays.asList(sysConfigService.getString("domain_keyword").split(","));
|
|
|
-
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
if (!superUserId.equals(SecurityUtils.getAuthenticatedUser().getId())) {
|
|
|
if (keywords.stream().anyMatch(keyword -> org.apache.commons.lang.StringUtils.equals(keyword, domain))) {
|
|
|
result.put("result", false);
|
|
|
@@ -147,7 +171,8 @@ public class DomainOrderService {
|
|
|
int dotIndex = domain.indexOf(".");
|
|
|
domain = domain.substring(0, dotIndex);
|
|
|
}
|
|
|
- List<DomainOrder> used = domainOrderRepo.searchUsedDomain("%" + domain + "%", OrderStatus.CANCELLED);
|
|
|
+ Pageable pageable = PageRequest.of(0, 10, Sort.by("createdAt").descending());
|
|
|
+ List<DomainOrder> used = domainOrderRepo.searchUsedDomain("%" + domain + "%", OrderStatus.CANCELLED,pageable).getContent();
|
|
|
|
|
|
String n = domain.substring(domain.length() - 1);
|
|
|
List<Map<String, Object>> recommend = new ArrayList<>();
|
|
|
@@ -171,9 +196,14 @@ public class DomainOrderService {
|
|
|
|
|
|
used.forEach(domainOrder -> {
|
|
|
Map<String, Object> sold = new HashMap<>();
|
|
|
- sold.put("domain", domainOrder.getDomainName().toLowerCase());
|
|
|
- sold.put("sold", true);
|
|
|
- result.add(sold);
|
|
|
+ if (!domainOrder.getDomainName().contains(".uni")) {
|
|
|
+ sold.put("domain", domainOrder.getDomainName().toLowerCase());
|
|
|
+ sold.put("sold", true);
|
|
|
+ result.add(sold);
|
|
|
+ }
|
|
|
+ if (result.size() > 9) {
|
|
|
+
|
|
|
+ }
|
|
|
});
|
|
|
return result;
|
|
|
}
|
|
|
@@ -220,12 +250,12 @@ public class DomainOrderService {
|
|
|
String domainName;
|
|
|
if (domain.contains(".")) {
|
|
|
int dotIndex = domain.indexOf(".");
|
|
|
- domainName = domain.substring(0, dotIndex);
|
|
|
+ domainName = domain.substring(0, dotIndex).toUpperCase();
|
|
|
} else {
|
|
|
- domainName = domain;
|
|
|
+ domainName = domain.toUpperCase();
|
|
|
}
|
|
|
InputStream is1 = this.getClass()
|
|
|
- .getResourceAsStream("/font/Akronim Regular_mianfeiziti1.ttf");
|
|
|
+ .getResourceAsStream("/font/VonwaonBitmap_16pxLite.ttf");
|
|
|
Font font1 = Font.createFont(Font.TRUETYPE_FONT, is1);
|
|
|
is1.close();
|
|
|
InputStream is2 = this.getClass()
|
|
|
@@ -262,17 +292,57 @@ public class DomainOrderService {
|
|
|
// ImageUtils.Fit.COVER), 40);
|
|
|
// g.drawImage(avatarImg, 334, 136, null);
|
|
|
|
|
|
- g.setColor(new Color(255, 255, 255));
|
|
|
- Font topFont = font1.deriveFont(Font.PLAIN, 240f);
|
|
|
|
|
|
- Font downFont = font2.deriveFont(Font.BOLD, 36f);
|
|
|
- ImageUtils.drawCenteredString(g, domainName, new Rectangle(0, 243, shareImg
|
|
|
- .getWidth(), 86), topFont);
|
|
|
- ImageUtils.drawCenteredString(g, ".NFT", new Rectangle(0, 462, shareImg
|
|
|
- .getWidth(), 86), topFont);
|
|
|
- g.setColor(new Color(255, 255, 255));
|
|
|
- ImageUtils.drawCenteredString(g, domain, new Rectangle(0, 612, shareImg
|
|
|
- .getWidth(), 12), downFont);
|
|
|
+ int domainLength = domainName.length();
|
|
|
+ if (domainLength > 10) {
|
|
|
+ g.setColor(new Color(255, 255, 255));
|
|
|
+ Font topFont = font1.deriveFont(Font.PLAIN, 130f);
|
|
|
+ Font downFont = font2.deriveFont(Font.BOLD, 36f);
|
|
|
+ int subIndex = domainLength / 3;
|
|
|
+ String str1 = domainName.substring(0, subIndex);
|
|
|
+ String str2 = domainName.substring(subIndex, subIndex + subIndex);
|
|
|
+ String str3 = domainName.substring(subIndex + subIndex, domainLength);
|
|
|
+ ImageUtils.drawCenteredString(g, str1, new Rectangle(0, 180, shareImg
|
|
|
+ .getWidth(), 86), topFont);
|
|
|
+ ImageUtils.drawCenteredString(g, str2, new Rectangle(0, 300, shareImg
|
|
|
+ .getWidth(), 86), topFont);
|
|
|
+ ImageUtils.drawCenteredString(g, str3, new Rectangle(0, 420, shareImg
|
|
|
+ .getWidth(), 86), topFont);
|
|
|
+ ImageUtils.drawCenteredString(g, ".NFT", new Rectangle(0, 540, shareImg
|
|
|
+ .getWidth(), 86), topFont);
|
|
|
+ g.setColor(new Color(255, 255, 255));
|
|
|
+ ImageUtils.drawCenteredString(g, domain, new Rectangle(0, 650, shareImg
|
|
|
+ .getWidth(), 12), downFont);
|
|
|
+ }
|
|
|
+ if (domainLength > 5 & domainLength <= 10) {
|
|
|
+ g.setColor(new Color(255, 255, 255));
|
|
|
+ Font topFont = font1.deriveFont(Font.PLAIN, 190f);
|
|
|
+ Font downFont = font2.deriveFont(Font.BOLD, 36f);
|
|
|
+ int subIndex = domainLength / 2;
|
|
|
+ String str1 = domainName.substring(0, subIndex);
|
|
|
+ String str2 = domainName.substring(subIndex, domainLength);
|
|
|
+ ImageUtils.drawCenteredString(g, str1, new Rectangle(0, 180, shareImg
|
|
|
+ .getWidth(), 86), topFont);
|
|
|
+ ImageUtils.drawCenteredString(g, str2, new Rectangle(0, 350, shareImg
|
|
|
+ .getWidth(), 86), topFont);
|
|
|
+ ImageUtils.drawCenteredString(g, ".NFT", new Rectangle(0, 520, shareImg
|
|
|
+ .getWidth(), 86), topFont);
|
|
|
+ g.setColor(new Color(255, 255, 255));
|
|
|
+ ImageUtils.drawCenteredString(g, domain, new Rectangle(0, 650, shareImg
|
|
|
+ .getWidth(), 12), downFont);
|
|
|
+ }
|
|
|
+ if (domainLength <= 5) {
|
|
|
+ g.setColor(new Color(255, 255, 255));
|
|
|
+ Font topFont = font1.deriveFont(Font.PLAIN, 240f);
|
|
|
+ Font downFont = font2.deriveFont(Font.BOLD, 36f);
|
|
|
+ ImageUtils.drawCenteredString(g, domainName, new Rectangle(17, 220, shareImg
|
|
|
+ .getWidth(), 86), topFont);
|
|
|
+ ImageUtils.drawCenteredString(g, ".NFT", new Rectangle(-10, 420, shareImg
|
|
|
+ .getWidth(), 86), topFont);
|
|
|
+ g.setColor(new Color(255, 255, 255));
|
|
|
+ ImageUtils.drawCenteredString(g, domain, new Rectangle(0, 620, shareImg
|
|
|
+ .getWidth(), 12), downFont);
|
|
|
+ }
|
|
|
|
|
|
//二维码
|
|
|
// QRCodeWriter qrCodeWriter = new QRCodeWriter();
|