7 Commits d322a28791 ... e0f14b67ba

Autor SHA1 Mensagem Data
  gao e0f14b67ba 数据库时区 2 dias atrás
  kongxiangyang e24ba8b06f 1 1 mês atrás
  kongxiangyang 37ef293c99 保险箱交易详情列表 所属区块链、币种筛选查询 1 mês atrás
  kongxiangyang 93414523fc refactor(utils): 将时间戳转换工具方法移至DateUtils类 1 mês atrás
  kongxiangyang 77b25c99ff 1.导出字段和列表保持一致 1 mês atrás
  kongxiangyang ffc5709abd 根据区块链跳转不同的地址 1 mês atrás
  kongxiangyang 96eb5f3431 1.交易详情列表时间筛选 1 mês atrás

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

@@ -1,12 +1,13 @@
 package com.crm.manager.controller;
 
 import com.crm.manager.service.VaultodyService;
+import com.crm.manager.util.BlockchainUtils;
+import com.crm.manager.util.DateUtils;
 import com.crm.rely.backend.core.dto.base.BaseResultDto;
 import com.crm.rely.backend.model.dto.export.TransactionItemExport;
 import com.crm.rely.backend.model.entity.vaultody.vaults.VaultTransactionsEntity;
 import com.crm.rely.backend.model.entity.vaultody.vaults.VaultTransactionsSearchEntity;
 import com.crm.rely.backend.model.pojo.table.TransactionItemTable;
-import com.crm.rely.backend.util.DateUtil;
 import com.crm.rely.backend.util.ExportUtil;
 import com.crm.rely.backend.util.FileProcessUtil;
 import com.google.common.collect.Lists;
@@ -20,10 +21,6 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
 import java.util.List;
 
 
@@ -65,42 +62,20 @@ public class VaultodyController {
      * @throws Exception
      */
     @PostMapping("/export")
-    public void export(@RequestBody VaultTransactionsEntity entity, HttpServletResponse response) throws Exception {
-        List<TransactionItemTable> items = vaultodyService.queryExportItems(entity);
+    public void export(@RequestBody VaultTransactionsSearchEntity entity, HttpServletResponse response) throws Exception {
+        List<TransactionItemTable> items = (List<TransactionItemTable>)searchList(entity).getData();
         List<TransactionItemExport> exportDtos = Lists.newArrayList();
         for (TransactionItemTable item : items) {
             TransactionItemExport exportDto = new TransactionItemExport();
             BeanUtils.copyProperties(item, exportDto);
-            if("ETH".equals(exportDto.getRecipientAmountUnit())){
-                exportDto.setTransactionId("https://tronscan.org/#/transaction/"+exportDto.getTransactionId());
-            }else {
-                exportDto.setTransactionId("https://etherscan.io/tx/"+exportDto.getTransactionId());
+            if(StringUtils.isNotBlank(item.getBlockchain()) && StringUtils.isNotBlank(item.getTransactionId())){
+                exportDto.setTransactionId(BlockchainUtils.getTransactionUrl(item.getBlockchain(), item.getTransactionId()));
             }
-            exportDto.setCreatedTimestamp(secondToDateTimeStr(item.getCreatedTimestamp()));
+            exportDto.setCreatedTimestamp(DateUtils.secondToDateTimeStr(item.getCreatedTimestamp()));
             exportDtos.add(exportDto);
         }
         ExportUtil.transferToResponse(FileProcessUtil.genExportFileName("VAULTODY_VAULT_TRANSACTIONS"), exportDtos,
                 TransactionItemExport.class, response);
     }
 
-    // 常用格式:yyyy-MM-dd HH:mm:ss
-    public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-
-    /**
-     * 秒级时间戳 → 日期字符串
-     * @param secondTimestamp 秒级时间戳 (如 1735458266)
-     * @return yyyy-MM-dd HH:mm:ss
-     */
-    public static String secondToDateTimeStr(long secondTimestamp) {
-        if (secondTimestamp <= 0) {
-            return null;
-        }
-        // 秒级时间戳转 Instant
-        Instant instant = Instant.ofEpochSecond(secondTimestamp);
-        // 转东八区时间(中国时区)
-        LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.of("Asia/Shanghai"));
-        // 格式化字符串
-        return localDateTime.format(FORMATTER);
-    }
-
 }

+ 3 - 2
crm-manager/src/main/java/com/crm/manager/dao/mapper/TransactionItemMapper.java

@@ -3,12 +3,13 @@ package com.crm.manager.dao.mapper;
 import com.crm.rely.backend.model.entity.vaultody.vaults.VaultTransactionsSearchEntity;
 import com.crm.rely.backend.model.pojo.table.TransactionItemTable;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
 @Mapper
 public interface TransactionItemMapper {
-    Integer countList(VaultTransactionsSearchEntity entity);
+    Integer countList(@Param("entity") VaultTransactionsSearchEntity entity, @Param("startSecond") Long startSecond, @Param("endSecond") Long endSecond);
 
-    List<TransactionItemTable> pageList(VaultTransactionsSearchEntity entity);
+    List<TransactionItemTable> pageList(@Param("entity") VaultTransactionsSearchEntity entity, @Param("startSecond") Long startSecond, @Param("endSecond") Long endSecond);
 }

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

@@ -14,8 +14,6 @@ public interface VaultodyService {
 
     BaseResultDto vaultsList() throws Exception;
 
-    List<TransactionItemTable> queryExportItems(VaultTransactionsEntity entity) throws Exception;
-
     void batchSave(List<TransactionItemTable> tables);
 
     List<TransactionItemTable> finAllByVaultId(String vaultId);

+ 14 - 9
crm-manager/src/main/java/com/crm/manager/service/impl/VaultodyServiceImpl.java

@@ -6,6 +6,7 @@ import com.crm.manager.repository.TransactionItemRepository;
 import com.crm.manager.service.SysConfigService;
 import com.crm.manager.service.SysVaultodyConfigService;
 import com.crm.manager.service.VaultodyService;
+import com.crm.manager.util.DateUtils;
 import com.crm.rely.backend.core.constant.Constants;
 import com.crm.rely.backend.core.dto.base.BaseResultDto;
 import com.crm.rely.backend.core.dto.base.PageDto;
@@ -364,13 +365,6 @@ public class VaultodyServiceImpl implements VaultodyService {
         return vaultTransaction;
     }
 
-    @Override
-    public List<TransactionItemTable> queryExportItems (VaultTransactionsEntity entity) throws Exception{
-        VaultTransactionsSearchEntity vaultTransactionsSearchEntity = new VaultTransactionsSearchEntity();
-        BeanUtils.copyProperties(entity, vaultTransactionsSearchEntity);
-        return transactionItemMapper.pageList(vaultTransactionsSearchEntity);
-    }
-
     @Override
     public void batchSave(List<TransactionItemTable> tables) {
         transactionItemRepository.saveAll(tables);
@@ -396,12 +390,23 @@ public class VaultodyServiceImpl implements VaultodyService {
             }
             batchSave(tables);
         }
-        Integer count = transactionItemMapper.countList(entity);
+
+        Long startSecond = null;
+        Long endSecond = null;
+
+        if(entity.getStartTime() != null){
+            startSecond = DateUtils.dateToSecondTimestamp(entity.getStartTime());
+        }
+        if (entity.getEndTime() != null){
+            endSecond = DateUtils.dateToSecondTimestamp(entity.getEndTime());
+        }
+
+        Integer count = transactionItemMapper.countList(entity,startSecond,endSecond);
         if (count == null || count <= 0) {
             return ResultWithPagerDto.success(new PageDto(), new ArrayList<>());
         }
         PageDto pageDto = PageDto.format(entity, count);
-        List<TransactionItemTable> dtos = transactionItemMapper.pageList(entity);
+        List<TransactionItemTable> dtos = transactionItemMapper.pageList(entity,startSecond,endSecond);
 
         if (dtos == null || dtos.size() <= 0) {
             throw new ServiceException(Constants.SYSTEM_ERROR);

+ 20 - 0
crm-manager/src/main/java/com/crm/manager/util/BlockchainUtils.java

@@ -0,0 +1,20 @@
+package com.crm.manager.util;
+
+public class BlockchainUtils {
+
+    public static String getTransactionUrl(String blockchain, String transactionId) {
+        String url = null;
+        switch (blockchain) {
+            case "ethereum":
+                url = "https://etherscan.io/tx/" + transactionId;
+                break;
+            case "tron":
+                url = "https://tronscan.org/#/transaction/" + transactionId;
+                break;
+            default:
+                break;
+        }
+        return url;
+    }
+
+}

+ 40 - 0
crm-manager/src/main/java/com/crm/manager/util/DateUtils.java

@@ -0,0 +1,40 @@
+package com.crm.manager.util;
+
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+
+public class DateUtils {
+
+    /**
+     * Date 转 秒级时间戳(数据库存的就是这个)
+     */
+    public static long dateToSecondTimestamp(Date date) {
+        if (date == null) {
+            return 0;
+        }
+        return date.getTime() / 1000; // 毫秒 → 秒(关键)
+    }
+
+    // 常用格式:yyyy-MM-dd HH:mm:ss
+    public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+    /**
+     * 秒级时间戳 → 日期字符串
+     * @param secondTimestamp 秒级时间戳 (如 1735458266)
+     * @return yyyy-MM-dd HH:mm:ss
+     */
+    public static String secondToDateTimeStr(long secondTimestamp) {
+        if (secondTimestamp <= 0) {
+            return null;
+        }
+        // 秒级时间戳转 Instant
+        Instant instant = Instant.ofEpochSecond(secondTimestamp);
+        // 转东八区时间(中国时区)
+        LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.of("Asia/Shanghai"));
+        // 格式化字符串
+        return localDateTime.format(FORMATTER);
+    }
+}

+ 1 - 1
crm-manager/src/main/resources/application-dev.yml

@@ -1,7 +1,7 @@
 spring:
   datasource:
     driver-class-name: com.mysql.cj.jdbc.Driver
-    url: jdbc:mysql://103.214.175.29:28571/cwg_vaultody?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&useSSL=false
+    url: jdbc:mysql://103.214.175.29:28571/cwg_vaultody?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&allowMultiQueries=true&useSSL=false
     username: root
     password: NSH01Y0GTmUNjgg6xw80qg==
 #  cloud:

+ 25 - 10
crm-manager/src/main/resources/mapper/TransactionItemMapper.xml

@@ -6,20 +6,33 @@
 
     <sql id="transactionItemWhere">
         <where>
-            <if test="senderAddress != null and senderAddress != ''">
-                and ti.`sender_address` LIKE CONCAT('%', #{senderAddress}, '%')
+            <if test="entity.senderAddress != null and entity.senderAddress != ''">
+                and ti.`sender_address` LIKE CONCAT('%', #{entity.senderAddress}, '%')
             </if>
-            <if test="recipientAddress != null and recipientAddress != ''">
-                and ti.`recipient_address` LIKE CONCAT('%', #{recipientAddress}, '%')
+            <if test="entity.recipientAddress != null and entity.recipientAddress != ''">
+                and ti.`recipient_address` LIKE CONCAT('%', #{entity.recipientAddress}, '%')
             </if>
-            <if test="senderLabel != null and senderLabel != ''">
-                and ti.`sender_label` LIKE CONCAT('%', #{senderLabel}, '%')
+            <if test="entity.senderLabel != null and entity.senderLabel != ''">
+                and ti.`sender_label` LIKE CONCAT('%', #{entity.senderLabel}, '%')
             </if>
-            <if test="recipientLabel != null and recipientLabel != ''">
-                and ti.`recipient_label` LIKE CONCAT('%', #{recipientLabel}, '%')
+            <if test="entity.recipientLabel != null and entity.recipientLabel != ''">
+                and ti.`recipient_label` LIKE CONCAT('%', #{entity.recipientLabel}, '%')
             </if>
-            <if test="vaultId != null and vaultId != ''">
-                and ti.`vault_id` = #{vaultId}
+            <if test="entity.vaultId != null and entity.vaultId != ''">
+                and ti.`vault_id` = #{entity.vaultId}
+            </if>
+            <if test="entity.blockchain != null and entity.blockchain != ''">
+                and ti.`blockchain` = #{entity.blockchain}
+            </if>
+            <if test="entity.unit != null and entity.unit != ''">
+                and ti.`recipient_amount_unit` = #{entity.unit}
+            </if>
+            <!-- 时间范围查询 -->
+            <if test="startSecond != null">
+                AND created_timestamp &gt;= #{startSecond}
+            </if>
+            <if test="endSecond != null">
+                AND created_timestamp &lt;= #{endSecond}
             </if>
         </where>
     </sql>
@@ -27,10 +40,12 @@
     <select id="countList" resultType="java.lang.Integer">
         select count(*) from transaction_item ti
         <include refid="transactionItemWhere"/>
+        order by ti.created_timestamp desc
     </select>
 
     <select id="pageList" resultType="com.crm.rely.backend.model.pojo.table.TransactionItemTable">
         select * from transaction_item ti
         <include refid="transactionItemWhere"/>
+        order by ti.created_timestamp desc
     </select>
 </mapper>

+ 18 - 22
crm-model/src/main/java/com/crm/rely/backend/model/dto/export/TransactionItemExport.java

@@ -5,37 +5,33 @@ import lombok.Data;
 
 @Data
 public class TransactionItemExport {
-    @ExcelProperty(value = "请求id", index = 0)
-    private String requestId;
-    @ExcelProperty(value = "链上真实交易哈希值", index = 1)
-    private String transactionId;
-    @ExcelProperty(value = "交易状态", index = 2)
+    @ExcelProperty(value = "交易状态", index = 0)
     private String status;
-    @ExcelProperty(value = "创建时间", index = 3)
+    @ExcelProperty(value = "创建时间", index = 1)
     private String createdTimestamp;
-
-    @ExcelProperty(value = "转出钱包地址", index = 4)
+    @ExcelProperty(value = "转出钱包地址", index = 2)
     private String senderAddress;
-    @ExcelProperty(value = "转出钱包币种", index = 5)
+    @ExcelProperty(value = "付款钱包名称", index = 3)
+    private String senderLabel;
+    @ExcelProperty(value = "转出币种", index = 4)
     private String senderAmountUnit;
-    @ExcelProperty(value = "转出货币金额", index = 6)
+    @ExcelProperty(value = "转出金额", index = 5)
     private String senderAmount;
-    @ExcelProperty(value = "转出钱包名称", index = 7)
-    private String senderLabel;
-
-    @ExcelProperty(value = "收款钱包地址", index = 8)
+    @ExcelProperty(value = "收款钱包地址", index = 6)
     private String recipientAddress;
-    @ExcelProperty(value = "收款钱包币种", index = 9)
+    @ExcelProperty(value = "收款钱包名称", index = 7)
+    private String recipientLabel;
+    @ExcelProperty(value = "收款币种", index = 8)
     private String recipientAmountUnit;
-    @ExcelProperty(value = "收到货币金额", index = 10)
+    @ExcelProperty(value = "收到金额", index = 9)
     private String recipientAmount;
-    @ExcelProperty(value = "收款钱包名称", index = 11)
-    private String recipientLabel;
-
-    @ExcelProperty(value = "所属区块链", index = 12)
+    @ExcelProperty(value = "所属区块链", index = 10)
     private String blockchain;
-    @ExcelProperty(value = "区块链手续费", index = 13)
+    @ExcelProperty(value = "区块链手续费", index = 11)
     private String feeAmount;
-    @ExcelProperty(value = "区块链手续费币种", index = 14)
+    @ExcelProperty(value = "手续费币种", index = 12)
     private String feeAmountUnit;
+    @ExcelProperty(value = "链上交易哈希", index = 13)
+    private String transactionId;
+
 }

+ 11 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/vaultody/vaults/VaultTransactionsEntity.java

@@ -2,6 +2,8 @@ package com.crm.rely.backend.model.entity.vaultody.vaults;
 
 import lombok.Data;
 
+import java.util.Date;
+
 /**
  * 获取保险箱交易记录入参
  */
@@ -37,4 +39,13 @@ public class VaultTransactionsEntity {
      * 收款钱包名称
      */
     private String recipientLabel;
+
+    /**
+     * 开始时间
+     */
+    private Date startTime;
+    /**
+     * 结束时间
+     */
+    private Date endTime;
 }

+ 25 - 5
crm-model/src/main/java/com/crm/rely/backend/model/entity/vaultody/vaults/VaultTransactionsSearchEntity.java

@@ -3,6 +3,8 @@ package com.crm.rely.backend.model.entity.vaultody.vaults;
 import com.crm.rely.backend.core.entity.base.BaseSearchPageEntity;
 import lombok.Data;
 
+import java.util.Date;
+
 @Data
 public class VaultTransactionsSearchEntity extends BaseSearchPageEntity {
     /**
@@ -10,11 +12,6 @@ public class VaultTransactionsSearchEntity extends BaseSearchPageEntity {
      */
     private String vaultId;
 
-    /**
-     * 交易状态
-     */
-    private String status;
-
     /**
      * 发送方保险库地址
      */
@@ -34,4 +31,27 @@ public class VaultTransactionsSearchEntity extends BaseSearchPageEntity {
      * 收款钱包名称
      */
     private String recipientLabel;
+    /**
+     * 开始时间
+     */
+    private Date startTime;
+    /**
+     * 结束时间
+     */
+    private Date endTime;
+
+    /**
+     * 交易状态
+     */
+    private String status;
+
+    /**
+     * 所属区块链
+     */
+    private String blockchain;
+
+    /**
+     * 币种
+     */
+    private String unit;
 }