Browse Source

保险箱交易记录接口改造(数据结构转换,整理出需要前端展示的字段)
导出保险箱交易记录改造(数据结构转换,整理出需要导出excel文件中的字段)

kongxiangyang 2 months ago
parent
commit
9672b06c83

+ 7 - 18
crm-manager/src/main/java/com/crm/manager/controller/VaultodyController.java

@@ -3,7 +3,7 @@ package com.crm.manager.controller;
 import com.crm.manager.service.VaultodyService;
 import com.crm.rely.backend.core.dto.base.BaseResultDto;
 import com.crm.rely.backend.model.dto.export.TransactionItemExport;
-import com.crm.rely.backend.model.dto.vaultody.vaults.response.TransactionItem;
+import com.crm.rely.backend.model.dto.vaultody.vaults.TransactionItemDto;
 import com.crm.rely.backend.model.entity.vaultody.vaults.VaultTransactionsEntity;
 import com.crm.rely.backend.util.ExportUtil;
 import com.crm.rely.backend.util.FileProcessUtil;
@@ -13,7 +13,10 @@ import org.apache.commons.lang.StringUtils;
 import org.hibernate.service.spi.ServiceException;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
 
@@ -59,25 +62,11 @@ public class VaultodyController {
      */
     @PostMapping("/export")
     public void export(@RequestBody VaultTransactionsEntity entity, HttpServletResponse response) throws Exception {
-        List<TransactionItem> items = vaultodyService.queryExportItems(entity);
+        List<TransactionItemDto> items = vaultodyService.queryExportItems(entity);
         List<TransactionItemExport> exportDtos = Lists.newArrayList();
-        for (TransactionItem item : items) {
+        for (TransactionItemDto item : items) {
             TransactionItemExport exportDto = new TransactionItemExport();
             BeanUtils.copyProperties(item, exportDto);
-            exportDto.setRecipientAddress(item.getRecipients().get(0).getAddress());
-            exportDto.setRecipientAddressType(item.getRecipients().get(0).getAddressType());
-            exportDto.setRecipientAmount(item.getRecipients().get(0).getAmount());
-            exportDto.setRecipientAmountUnit(item.getRecipients().get(0).getAmountUnit());
-            exportDto.setRecipientIsVaultAddress(item.getRecipients().get(0).getIsVaultAddress());
-            exportDto.setRecipientLabel(item.getRecipients().get(0).getLabel());
-            exportDto.setSenderAddress(item.getSenders().get(0).getAddress());
-            exportDto.setSenderAddressType(item.getSenders().get(0).getAddressType());
-            exportDto.setSenderAmount(item.getSenders().get(0).getAmount());
-            exportDto.setSenderAmountUnit(item.getSenders().get(0).getAmountUnit());
-            exportDto.setSenderIsVaultAddress(item.getSenders().get(0).getIsVaultAddress());
-            exportDto.setSenderLabel(item.getSenders().get(0).getLabel());
-            exportDto.setAmount(item.getTransactionFee().getAmount());
-            exportDto.setAmountUnit(item.getTransactionFee().getAmountUnit());
             exportDtos.add(exportDto);
         }
         ExportUtil.transferToResponse(FileProcessUtil.genExportFileName("VAULTODY_VAULT_TRANSACTIONS"), exportDtos,

+ 2 - 2
crm-manager/src/main/java/com/crm/manager/service/VaultodyService.java

@@ -1,7 +1,7 @@
 package com.crm.manager.service;
 
 import com.crm.rely.backend.core.dto.base.BaseResultDto;
-import com.crm.rely.backend.model.dto.vaultody.vaults.response.TransactionItem;
+import com.crm.rely.backend.model.dto.vaultody.vaults.TransactionItemDto;
 import com.crm.rely.backend.model.entity.vaultody.vaults.VaultTransactionsEntity;
 
 import java.util.List;
@@ -13,5 +13,5 @@ public interface VaultodyService {
 
     BaseResultDto vaultsTransactions(VaultTransactionsEntity entity) throws Exception;
 
-    List<TransactionItem> queryExportItems(VaultTransactionsEntity entity) throws Exception;
+    List<TransactionItemDto> queryExportItems(VaultTransactionsEntity entity) throws Exception;
 }

+ 41 - 4
crm-manager/src/main/java/com/crm/manager/service/impl/VaultodyServiceImpl.java

@@ -10,14 +10,19 @@ import com.crm.rely.backend.core.exception.ServiceException;
 import com.crm.rely.backend.core.pojo.table.SysConfigTable;
 import com.crm.rely.backend.model.config.VaultodyConfig;
 import com.crm.rely.backend.model.constant.ConfigConstants;
+import com.crm.rely.backend.model.dto.vaultody.vaults.VaultTransaction;
+import com.crm.rely.backend.model.dto.vaultody.vaults.TransactionItemDto;
 import com.crm.rely.backend.model.dto.vaultody.vaults.VaultodyVaultsListDto;
 import com.crm.rely.backend.model.dto.vaultody.vaults.response.*;
 import com.crm.rely.backend.model.entity.vaultody.vaults.VaultTransactionsEntity;
 import com.crm.rely.backend.model.pojo.table.SysVaultodyConfigTable;
 import com.crm.rely.backend.util.AESUtil;
 import com.crm.rely.backend.util.HttpUtil;
+import com.crm.rely.backend.util.UUIDUtil;
+import com.google.common.collect.Lists;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
+import org.jetbrains.annotations.NotNull;
 import org.jsoup.Connection;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -285,12 +290,44 @@ public class VaultodyServiceImpl implements VaultodyService {
             items.add(item);
             data.setItems(items);
         }
-        return BaseResultDto.success(data);
+        VaultTransaction vaultTransaction = getVaultTransaction(data);
+        return BaseResultDto.success(vaultTransaction);
+    }
+
+    private VaultTransaction getVaultTransaction(ResponseData data) {
+        VaultTransaction vaultTransaction = new VaultTransaction();
+        vaultTransaction.setHasMore(data.getHasMore());
+        vaultTransaction.setLimit(data.getLimit());
+        vaultTransaction.setStartingAfter(data.getStartingAfter());
+        List<TransactionItemDto> list = Lists.newArrayList();
+        for (TransactionItem item : data.getItems()) {
+            TransactionItemDto dto = new TransactionItemDto();
+            dto.setRequestId(UUIDUtil.getUUID());
+            dto.setId(item.getId());
+            dto.setTransactionId(item.getTransactionId());
+            dto.setStatus(item.getStatus());
+            dto.setCreatedTimestamp(item.getCreatedTimestamp());
+            dto.setSenderAddress(item.getSenders().get(0).getAddress());
+            dto.setSenderIsVaultAddress(item.getSenders().get(0).getIsVaultAddress());
+            dto.setSenderAmountUnit(item.getSenders().get(0).getAmountUnit());
+            dto.setSenderAmount(item.getSenders().get(0).getAmount());
+            dto.setRecipientAddress(item.getRecipients().get(0).getAddress());
+            dto.setRecipientIsVaultAddress(item.getRecipients().get(0).getIsVaultAddress());
+            dto.setRecipientAmountUnit(item.getRecipients().get(0).getAmountUnit());
+            dto.setRecipientAmount(item.getRecipients().get(0).getAmount());
+            dto.setBlockchain(item.getBlockchain());
+            dto.setMinedInBlockHeight(item.getMinedInBlockHeight());
+            dto.setFeeAmount(item.getTransactionFee().getAmount());
+            dto.setFeeAmountUnit(item.getTransactionFee().getAmountUnit());
+            list.add(dto);
+        }
+        vaultTransaction.setList(list);
+        return vaultTransaction;
     }
 
     @Override
-    public List<TransactionItem> queryExportItems (VaultTransactionsEntity entity) throws Exception{
-        ResponseData result = (ResponseData)vaultsTransactions(entity).getData();
-        return result.getItems();
+    public List<TransactionItemDto> queryExportItems (VaultTransactionsEntity entity) throws Exception{
+        VaultTransaction result = (VaultTransaction)vaultsTransactions(entity).getData();
+        return result.getList();
     }
 }

+ 32 - 46
crm-model/src/main/java/com/crm/rely/backend/model/dto/export/TransactionItemExport.java

@@ -5,55 +5,41 @@ import lombok.Data;
 
 @Data
 public class TransactionItemExport {
-    @ExcelProperty(value = "blockchain", index = 0)
-    private String blockchain;
-    @ExcelProperty(value = "createdTimestamp", index = 1)
-    private Long createdTimestamp;
-    @ExcelProperty(value = "direction", index = 2)
-    private String direction;
-    @ExcelProperty(value = "hasTokenTransfer", index = 3)
-    private String hasTokenTransfer;
-    @ExcelProperty(value = "id", index = 4)
+    @ExcelProperty(value = "请求id", index = 0)
+    private String requestId;
+    @ExcelProperty(value = "交易流水id", index = 1)
     private String id;
-    @ExcelProperty(value = "isInternal", index = 5)
-    private String isInternal;
-    @ExcelProperty(value = "minedInBlockHeight", index = 6)
-    private String minedInBlockHeight;
-    @ExcelProperty(value = "network", index = 7)
-    private String network;
-
-    @ExcelProperty(value = "recipientAddress", index = 8)
-    private String recipientAddress;
-    @ExcelProperty(value = "recipientAddressType", index = 9)
-    private String recipientAddressType;
-    @ExcelProperty(value = "recipientAmount", index = 10)
-    private String recipientAmount;
-    @ExcelProperty(value = "recipientAmountUnit", index = 11)
-    private String recipientAmountUnit;
-    @ExcelProperty(value = "recipientIsVaultAddress", index = 12)
-    private String recipientIsVaultAddress;
-    @ExcelProperty(value = "recipientLabel", index = 13)
-    private String recipientLabel;
+    @ExcelProperty(value = "链上真实交易哈希值", index = 2)
+    private String transactionId;
+    @ExcelProperty(value = "交易状态", index = 3)
+    private String status;
+    @ExcelProperty(value = "创建时间", index = 4)
+    private Long createdTimestamp;
 
-    @ExcelProperty(value = "senderAddress", index = 14)
+    @ExcelProperty(value = "转出钱包地址", index = 5)
     private String senderAddress;
-    @ExcelProperty(value = "senderAddressType", index = 15)
-    private String senderAddressType;
-    @ExcelProperty(value = "senderAmount", index = 16)
-    private String senderAmount;
-    @ExcelProperty(value = "senderAmountUnit", index = 17)
-    private String senderAmountUnit;
-    @ExcelProperty(value = "senderIsVaultAddress", index = 18)
+    @ExcelProperty(value = "转出钱包是否内部钱包", index = 6)
     private String senderIsVaultAddress;
-    @ExcelProperty(value = "senderLabel", index = 19)
-    private String senderLabel;
+    @ExcelProperty(value = "转出钱包币种", index = 7)
+    private String senderAmountUnit;
+    @ExcelProperty(value = "转出货币金额", index = 8)
+    private String senderAmount;
 
-    @ExcelProperty(value = "status", index = 20)
-    private String status;
-    @ExcelProperty(value = "amount", index = 21)
-    private String amount;
-    @ExcelProperty(value = "amountUnit", index = 22)
-    private String amountUnit;
-    @ExcelProperty(value = "transactionId", index = 23)
-    private String transactionId;
+    @ExcelProperty(value = "收款钱包地址", index = 9)
+    private String recipientAddress;
+    @ExcelProperty(value = "收款钱包是否内部钱包", index = 10)
+    private String recipientIsVaultAddress;
+    @ExcelProperty(value = "收款钱包币种", index = 11)
+    private String recipientAmountUnit;
+    @ExcelProperty(value = "收到货币金额", index = 12)
+    private String recipientAmount;
+
+    @ExcelProperty(value = "所属区块链", index = 13)
+    private String blockchain;
+    @ExcelProperty(value = "区块高度", index = 14)
+    private String minedInBlockHeight;
+    @ExcelProperty(value = "区块链手续费", index = 15)
+    private String feeAmount;
+    @ExcelProperty(value = "区块链手续费币种", index = 16)
+    private String feeAmountUnit;
 }

+ 27 - 0
crm-model/src/main/java/com/crm/rely/backend/model/dto/vaultody/vaults/TransactionItemDto.java

@@ -0,0 +1,27 @@
+package com.crm.rely.backend.model.dto.vaultody.vaults;
+
+import lombok.Data;
+
+@Data
+public class TransactionItemDto {
+    private String requestId;
+    private String id;
+    private String transactionId;
+    private String status;
+    private Long createdTimestamp;
+
+    private String senderAddress;
+    private String senderIsVaultAddress;
+    private String senderAmountUnit;
+    private String senderAmount;
+
+    private String recipientAddress;
+    private String recipientIsVaultAddress;
+    private String recipientAmountUnit;
+    private String recipientAmount;
+
+    private String blockchain;
+    private String minedInBlockHeight;
+    private String feeAmount;
+    private String feeAmountUnit;
+}

+ 13 - 0
crm-model/src/main/java/com/crm/rely/backend/model/dto/vaultody/vaults/VaultTransaction.java

@@ -0,0 +1,13 @@
+package com.crm.rely.backend.model.dto.vaultody.vaults;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class VaultTransaction {
+    private Integer limit;
+    private String startingAfter;
+    private Boolean hasMore;
+    private List<TransactionItemDto> list;
+}