wangqifan 2 лет назад
Родитель
Сommit
ce4dfd454b
1 измененных файлов с 13 добавлено и 13 удалено
  1. 13 13
      src/main/java/com/izouma/nineth/service/DomainOrderService.java

+ 13 - 13
src/main/java/com/izouma/nineth/service/DomainOrderService.java

@@ -104,7 +104,7 @@ public class DomainOrderService {
         return m.find();
     }
 
-    public DomainOrder create(Long userId, String domain, BigDecimal price, Long year) throws FontFormatException, IOException, WriterException {
+    public DomainOrder create(Long userId, String domain, BigDecimal price, Long year) {
         AtomicBoolean checkPoint = checkPoint(userId);
         List<DomainOrder> notPaidOrders = domainOrderRepo.findAllByUserIdAndOrderStatus(userId, OrderStatus.NOT_PAID);
         Long superUserId = Long.valueOf(sysConfigService.getString("domain_superUserId"));
@@ -157,18 +157,6 @@ public class DomainOrderService {
         DomainOrder domainOrder = new DomainOrder();
 //        domainOrder.setPic(Collections.singletonList(fileObject));
 //        domain = domain.replaceAll("[^a-zA-Z0-9\\u4E00-\\u9FA5]", "");
-        BufferedImage img = domainImg(domainOrder.getDomainName());
-        ByteArrayOutputStream os = new ByteArrayOutputStream();
-        ImageIO.write(img, "jpg", os);
-        InputStream input = new ByteArrayInputStream(os.toByteArray());
-        String path = "image/" + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date())
-                + RandomStringUtils.randomAlphabetic(8) + ".jpg";
-        String realUrl = storageService.uploadFromInputStream(input, path);
-        FileObject fileObject = new FileObject();
-        fileObject.setName(domainOrder.getDomainName());
-        fileObject.setType("image/jpeg");
-        fileObject.setUrl(realUrl);
-        domainOrder.setPic(Collections.singletonList(fileObject));
         domainOrder.setPicName(domain);
         domainOrder.setPrice(price);
         domainOrder.setDomainName((domain + ".nft").toLowerCase());
@@ -387,8 +375,20 @@ public class DomainOrderService {
         if (!domainOrder.getOrderStatus().equals(OrderStatus.NOT_PAID)) {
             throw new BusinessException("订单已经处理");
         }
+        BufferedImage img = domainImg(domainOrder.getDomainName());
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        ImageIO.write(img, "jpg", os);
+        InputStream input = new ByteArrayInputStream(os.toByteArray());
+        String path = "image/" + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date())
+                + RandomStringUtils.randomAlphabetic(8) + ".jpg";
+        String realUrl = storageService.uploadFromInputStream(input, path);
+        FileObject fileObject = new FileObject();
+        fileObject.setName(domainOrder.getDomainName());
+        fileObject.setType("image/jpeg");
+        fileObject.setUrl(realUrl);
         domainOrder.setOrderStatus(OrderStatus.FINISH);
         domainOrder.setPayMethod(payMethod);
+        domainOrder.setPic(Collections.singletonList(fileObject));
         domainOrder.setTransactionId(transactionId);
 //        domainOrder.setStatus(CollectionStatus.SUCCESS);
         domainOrder.setCreateAssetId(createAsset(domainOrder));