gao 1 месяц назад
Родитель
Сommit
e3bc3b46c3
34 измененных файлов с 1317 добавлено и 377 удалено
  1. 2 8
      crm-model/src/main/java/com/crm/rely/backend/model/constant/ConfigConstants.java
  2. 49 0
      crm-model/src/main/java/com/crm/rely/backend/model/dto/settlement/SettlementDepositDto.java
  3. 10 0
      crm-model/src/main/java/com/crm/rely/backend/model/dto/settlement/SettlementValidateDto.java
  4. 62 0
      crm-model/src/main/java/com/crm/rely/backend/model/dto/settlement/SettlementWithdrawDto.java
  5. 70 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/base/MerchantPayInRequestEntity.java
  6. 87 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/base/MerchantPayOutRequestEntity.java
  7. 0 59
      crm-model/src/main/java/com/crm/rely/backend/model/entity/base/SettlementBaseEntity.java
  8. 39 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/settlement/SettlementDepositListSearchEntity.java
  9. 2 19
      crm-model/src/main/java/com/crm/rely/backend/model/entity/settlement/SettlementValidateDepositEntity.java
  10. 2 19
      crm-model/src/main/java/com/crm/rely/backend/model/entity/settlement/SettlementValidateWithdrawEntity.java
  11. 38 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/settlement/SettlementWithdrawListSearchEntity.java
  12. 22 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/settlement/log/SettlementCallbackLogAddEntity.java
  13. 15 2
      crm-model/src/main/java/com/crm/rely/backend/model/entity/settlement/vaultody/VaultodyDepositRequestEntity.java
  14. 2 2
      crm-model/src/main/java/com/crm/rely/backend/model/entity/settlement/vaultody/VaultodyWithdrawRequestEntity.java
  15. 27 0
      crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/SettlementCallbackLogTable.java
  16. 14 4
      crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/SettlementDepositRecordTable.java
  17. 14 8
      crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/SettlementWithdrawRecordTable.java
  18. 120 0
      crm-model/src/main/java/com/crm/rely/backend/model/util/AESJsUtil.java
  19. 104 0
      crm-model/src/main/java/com/crm/rely/backend/model/util/MapToEntityConverterUtil.java
  20. 32 4
      crm-settlement/src/main/java/com/crm/settlement/controller/SettlementController.java
  21. 0 11
      crm-settlement/src/main/java/com/crm/settlement/controller/VaultodyController.java
  22. 6 0
      crm-settlement/src/main/java/com/crm/settlement/dao/mapper/SettlementDepositRecordMapper.java
  23. 4 0
      crm-settlement/src/main/java/com/crm/settlement/dao/mapper/SettlementWithdrawRecordMapper.java
  24. 10 0
      crm-settlement/src/main/java/com/crm/settlement/dao/repository/SettlementCallbackLogRepository.java
  25. 2 0
      crm-settlement/src/main/java/com/crm/settlement/dao/repository/SettlementDepositRecordRepository.java
  26. 2 0
      crm-settlement/src/main/java/com/crm/settlement/dao/repository/SettlementWithdrawRecordRepository.java
  27. 9 0
      crm-settlement/src/main/java/com/crm/settlement/service/SettlementLogService.java
  28. 18 5
      crm-settlement/src/main/java/com/crm/settlement/service/SettlementService.java
  29. 25 0
      crm-settlement/src/main/java/com/crm/settlement/service/impl/SettlementLogServiceImpl.java
  30. 321 184
      crm-settlement/src/main/java/com/crm/settlement/service/impl/SettlementServiceImpl.java
  31. 34 28
      crm-settlement/src/main/java/com/crm/settlement/service/impl/VaultodyServiceImpl.java
  32. 39 24
      crm-settlement/src/main/java/com/crm/settlement/service/impl/base/BaseSettlementServiceImpl.java
  33. 68 0
      crm-settlement/src/main/resources/mapper/SettlementDepositRecordMapper.xml
  34. 68 0
      crm-settlement/src/main/resources/mapper/SettlementWithdrawRecordMapper.xml

+ 2 - 8
crm-model/src/main/java/com/crm/rely/backend/model/constant/ConfigConstants.java

@@ -19,17 +19,11 @@ public class ConfigConstants {
      * 入金回调
      */
     public static final String DEPOSIT_CALLBACK = "DEPOSIT_CALLBACK";
-    /**
-     * 入金回调重试
-     */
-    public static final String DEPOSIT_RETRY_CALLBACK = "DEPOSIT_RETRY_CALLBACK";
 
     /**
      * 出金回调
      */
     public static final String WITHDRAW_CALLBACK = "WITHDRAW_CALLBACK";
-    /**
-     * 出金回调重试
-     */
-    public static final String WITHDRAW_RETRY_CALLBACK = "WITHDRAW_RETRY_CALLBACK";
+
+
 }

+ 49 - 0
crm-model/src/main/java/com/crm/rely/backend/model/dto/settlement/SettlementDepositDto.java

@@ -0,0 +1,49 @@
+package com.crm.rely.backend.model.dto.settlement;
+
+import com.crm.rely.backend.core.dto.base.BaseInfoDto;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class SettlementDepositDto extends BaseInfoDto {
+
+    private String merchantId;
+
+    private String serial;
+
+    private Long login;
+
+    private String code;
+
+    private String name;
+
+    private String email;
+
+    private String phone;
+
+    private String extParam;
+
+    private BigDecimal amount;
+
+    private String currency;
+
+    private String bankCode;
+
+    private String channelCode;
+
+    private Integer status;
+
+    private BigDecimal callbackAmount;
+
+    private String callbackCurrency;
+
+    private String callbackData;
+
+    private Integer callbackMerchantStatus;
+
+    private Date callbackMerchantTime;
+
+
+}

+ 10 - 0
crm-model/src/main/java/com/crm/rely/backend/model/dto/settlement/SettlementValidateDto.java

@@ -0,0 +1,10 @@
+package com.crm.rely.backend.model.dto.settlement;
+
+import lombok.Data;
+
+@Data
+public class SettlementValidateDto {
+
+    private Integer status;
+
+}

+ 62 - 0
crm-model/src/main/java/com/crm/rely/backend/model/dto/settlement/SettlementWithdrawDto.java

@@ -0,0 +1,62 @@
+package com.crm.rely.backend.model.dto.settlement;
+
+import com.crm.rely.backend.core.dto.base.BaseInfoDto;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class SettlementWithdrawDto extends BaseInfoDto {
+
+    private String merchantId;
+
+    private String serial;
+
+    private Long login;
+
+    private String code;
+
+    private String name;
+
+    private String email;
+
+    private String phone;
+
+    private String extParam;
+
+    private BigDecimal amount;
+
+    private String currency;
+
+    private String bankCode;
+
+    private String address;
+
+    private String bankUname;
+
+    private String bankCardNum;
+
+    private String bankName;
+
+    private String bankBranchName;
+
+    private String bankAddr;
+
+    private String swiftCode;
+
+    private String channelCode;
+
+    private Integer status;
+
+    private BigDecimal callbackAmount;
+
+    private String callbackCurrency;
+
+    private String callbackData;
+
+    private Integer callbackMerchantStatus;
+
+    private Date callbackMerchantTime;
+
+}

+ 70 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/base/MerchantPayInRequestEntity.java

@@ -0,0 +1,70 @@
+package com.crm.rely.backend.model.entity.base;
+
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class MerchantPayInRequestEntity {
+
+    @NotNull(message = "merchantId not null")
+    @NotBlank(message = "merchantId not blank")
+    private String merchantId;
+
+    @NotNull(message = "serial not null")
+    @NotBlank(message = "serial not blank")
+    private String serial;
+
+    @NotNull(message = "login not null")
+    private Long login;
+
+    @NotNull(message = "channelCode not null")
+    @NotBlank(message = "channelCode not blank")
+    private String channelCode;
+
+    @NotNull(message = "amount not null")
+    private BigDecimal amount;
+
+    @NotNull(message = "currency not null")
+    @NotBlank(message = "currency not blank")
+    private String currency;
+
+    @NotNull(message = "bankCode not null")
+    @NotBlank(message = "bankCode not blank")
+    private String bankCode;
+
+    @NotNull(message = "code not null")
+    @NotBlank(message = "code not blank")
+    private String code;
+
+    @NotNull(message = "name not null")
+    @NotBlank(message = "name not blank")
+    private String name;
+
+    @NotNull(message = "email not null")
+    @NotBlank(message = "email not blank")
+    private String email;
+
+    @NotNull(message = "phone not null")
+    @NotBlank(message = "phone not blank")
+    private String phone;
+
+    @NotNull(message = "callbackUrl not null")
+    @NotBlank(message = "callbackUrl not blank")
+    private String callbackUrl;
+
+    @NotNull(message = "requestTime not null")
+    private Long requestTime;
+
+    @NotNull(message = "sign not null")
+    @NotBlank(message = "sign not blank")
+    private String sign;
+
+    /**
+     * 扩展参数
+     */
+    private String extParam;
+
+}

+ 87 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/base/MerchantPayOutRequestEntity.java

@@ -0,0 +1,87 @@
+package com.crm.rely.backend.model.entity.base;
+
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class MerchantPayOutRequestEntity {
+
+    @NotNull(message = "merchantId not null")
+    @NotBlank(message = "merchantId not blank")
+    private String merchantId;
+
+    @NotNull(message = "serial not null")
+    @NotBlank(message = "serial not blank")
+    private String serial;
+
+    @NotNull(message = "login not null")
+    private Long login;
+
+    @NotNull(message = "channelCode not null")
+    @NotBlank(message = "channelCode not blank")
+    private String channelCode;
+
+    @NotNull(message = "amount not null")
+    private BigDecimal amount;
+
+    @NotNull(message = "currency not null")
+    @NotBlank(message = "currency not blank")
+    private String currency;
+
+    @NotNull(message = "bankCode not null")
+    @NotBlank(message = "bankCode not blank")
+    private String bankCode;
+
+    @NotNull(message = "code not null")
+    @NotBlank(message = "code not blank")
+    private String code;
+
+    @NotNull(message = "name not null")
+    @NotBlank(message = "name not blank")
+    private String name;
+
+    @NotNull(message = "email not null")
+    @NotBlank(message = "email not blank")
+    private String email;
+
+    @NotNull(message = "phone not null")
+    @NotBlank(message = "phone not blank")
+    private String phone;
+
+    @NotNull(message = "callbackUrl not null")
+    @NotBlank(message = "callbackUrl not blank")
+    private String callbackUrl;
+
+    @NotNull(message = "requestTime not null")
+    private Long requestTime;
+
+    @NotNull(message = "sign not null")
+    @NotBlank(message = "sign not blank")
+    private String sign;
+
+    /**
+     * 扩展参数
+     */
+    private String extParam;
+
+    private String address;
+
+    //银行用户名
+    private String bankUname;
+
+    //银行卡号
+    private String bankCardNum;
+
+    //银行名称
+    private String bankName;
+
+    private String bankBranchName;
+
+    private String bankAddr;
+
+    private String swiftCode;
+
+}

+ 0 - 59
crm-model/src/main/java/com/crm/rely/backend/model/entity/base/SettlementBaseEntity.java

@@ -1,59 +0,0 @@
-package com.crm.rely.backend.model.entity.base;
-
-import jakarta.validation.constraints.NotBlank;
-import jakarta.validation.constraints.NotNull;
-import lombok.Data;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-@Data
-public class SettlementBaseEntity {
-
-    @NotBlank
-    private String merchantId;
-
-    @NotBlank
-    private String channelCode;
-
-    @NotNull
-    @NotBlank
-    private String serial;
-
-    @NotNull
-    private BigDecimal amount;
-
-    @NotNull
-    @NotBlank
-    private String currency;
-
-    @NotNull
-    @NotBlank
-    private String callbackUrl;
-
-    @NotNull
-    private Date requestTime;
-
-    @NotNull
-    @NotBlank
-    private String sign;
-
-    private String address;
-
-    private String bankUname;
-
-    private String bankCardNum;
-
-    private String bankName;
-
-    private String bankBranchName;
-
-    private String bankAddr;
-
-    private String swiftCode;
-
-    private String cvv;
-
-    private String expiryMonth;
-
-}

+ 39 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/settlement/SettlementDepositListSearchEntity.java

@@ -0,0 +1,39 @@
+package com.crm.rely.backend.model.entity.settlement;
+
+import com.crm.rely.backend.core.entity.base.BaseDateAndPageSearchEntity;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+@Data
+public class SettlementDepositListSearchEntity extends BaseDateAndPageSearchEntity {
+
+    @NotNull
+    @NotBlank
+    private String merchantId;
+
+    private String serial;
+
+    private Long login;
+
+    private String name;
+
+    private String email;
+
+    private String channelCode;
+
+    private Integer callbackMerchantStatus;
+
+    @NotBlank
+    @NotNull
+    private String sign;
+
+    @NotNull
+    private Long requestTime;
+
+    private Integer current;
+
+    private Integer row;
+
+
+}

+ 2 - 19
crm-model/src/main/java/com/crm/rely/backend/model/entity/settlement/SettlementDepositEntity.java → crm-model/src/main/java/com/crm/rely/backend/model/entity/settlement/SettlementValidateDepositEntity.java

@@ -4,11 +4,8 @@ import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
 import lombok.Data;
 
-import java.math.BigDecimal;
-import java.util.Date;
-
 @Data
-public class SettlementDepositEntity {
+public class SettlementValidateDepositEntity {
 
     @NotBlank
     private String merchantId;
@@ -21,21 +18,7 @@ public class SettlementDepositEntity {
     private String serial;
 
     @NotNull
-    private BigDecimal callbackAmount;
-
-    @NotNull
-    @NotBlank
-    private String callbackCurrency;
-
-    @NotNull
-    private Integer status;
-
-    @NotNull
-    @NotBlank
-    private String callbackSerial;
-
-    @NotNull
-    private Date requestTime;
+    private Long requestTime;
 
     @NotNull
     @NotBlank

+ 2 - 19
crm-model/src/main/java/com/crm/rely/backend/model/entity/settlement/SettlementWithdrawEntity.java → crm-model/src/main/java/com/crm/rely/backend/model/entity/settlement/SettlementValidateWithdrawEntity.java

@@ -4,11 +4,8 @@ import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
 import lombok.Data;
 
-import java.math.BigDecimal;
-import java.util.Date;
-
 @Data
-public class SettlementWithdrawEntity {
+public class SettlementValidateWithdrawEntity {
 
     @NotBlank
     private String merchantId;
@@ -21,21 +18,7 @@ public class SettlementWithdrawEntity {
     private String serial;
 
     @NotNull
-    private BigDecimal callbackAmount;
-
-    @NotNull
-    @NotBlank
-    private String callbackCurrency;
-
-    @NotNull
-    private Integer status;
-
-    @NotNull
-    @NotBlank
-    private String callbackSerial;
-
-    @NotNull
-    private Date requestTime;
+    private Long requestTime;
 
     @NotNull
     @NotBlank

+ 38 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/settlement/SettlementWithdrawListSearchEntity.java

@@ -0,0 +1,38 @@
+package com.crm.rely.backend.model.entity.settlement;
+
+import com.crm.rely.backend.core.entity.base.BaseDateAndPageSearchEntity;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+@Data
+public class SettlementWithdrawListSearchEntity extends BaseDateAndPageSearchEntity {
+
+    @NotNull
+    @NotBlank
+    private String merchantId;
+
+    private String serial;
+
+    private Long login;
+
+    private String name;
+
+    private String email;
+
+    private String channelCode;
+
+    private Integer callbackMerchantStatus;
+
+    @NotBlank
+    @NotNull
+    private String sign;
+
+    @NotNull
+    private Long requestTime;
+
+    private Integer current;
+
+    private Integer row;
+
+}

+ 22 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/settlement/log/SettlementCallbackLogAddEntity.java

@@ -0,0 +1,22 @@
+package com.crm.rely.backend.model.entity.settlement.log;
+
+import com.crm.rely.backend.core.entity.base.BaseAddEntity;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class SettlementCallbackLogAddEntity extends BaseAddEntity {
+
+    private String merchantId;
+
+    private String serial;
+
+    private BigDecimal amount;
+
+    private String channelCode;
+
+    private String callbackUrl;
+
+    private String callbackData;
+}

+ 15 - 2
crm-model/src/main/java/com/crm/rely/backend/model/entity/settlement/vaultody/VaultodyDepositRequestEntity.java

@@ -1,10 +1,23 @@
 package com.crm.rely.backend.model.entity.settlement.vaultody;
 
-import com.crm.rely.backend.model.entity.base.SettlementBaseEntity;
+import com.crm.rely.backend.model.entity.base.MerchantPayInRequestEntity;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
 import lombok.Data;
 
 @Data
-public class VaultodyDepositRequestEntity extends SettlementBaseEntity {
+public class VaultodyDepositRequestEntity extends MerchantPayInRequestEntity {
 
+    @NotNull(message = "bankName not null")
+    @NotBlank(message = "bankName not blank")
+    private String bankName;
+
+    @NotNull(message = "bankEnName not null")
+    @NotBlank(message = "bankEnName not blank")
+    private String bankEnName;
+
+    @NotNull(message = "bankCurrency not null")
+    @NotBlank(message = "bankCurrency not blank")
+    private String bankCurrency;
 
 }

+ 2 - 2
crm-model/src/main/java/com/crm/rely/backend/model/entity/settlement/vaultody/VaultodyWithdrawRequestEntity.java

@@ -1,10 +1,10 @@
 package com.crm.rely.backend.model.entity.settlement.vaultody;
 
-import com.crm.rely.backend.model.entity.base.SettlementBaseEntity;
+import com.crm.rely.backend.model.entity.base.MerchantPayOutRequestEntity;
 import lombok.Data;
 
 @Data
-public class VaultodyWithdrawRequestEntity extends SettlementBaseEntity {
+public class VaultodyWithdrawRequestEntity extends MerchantPayOutRequestEntity {
 
 
 }

+ 27 - 0
crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/SettlementCallbackLogTable.java

@@ -0,0 +1,27 @@
+package com.crm.rely.backend.model.pojo.table;
+
+import com.crm.rely.backend.core.pojo.BaseTable;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Table;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+@Entity
+@Table(name = "settlement_callback_log")
+public class SettlementCallbackLogTable extends BaseTable {
+
+    private String merchantId;
+
+    private String serial;
+
+    private BigDecimal amount;
+
+    private String channelCode;
+
+    private String callbackUrl;
+
+    private String callbackData;
+
+}

+ 14 - 4
crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/SettlementDepositRecordTable.java

@@ -19,6 +19,18 @@ public class SettlementDepositRecordTable extends BaseTable {
     private String merchantId;
 
     private String serial;
+
+    private Long login;
+
+    private String code;
+
+    private String name;
+
+    private String email;
+
+    private String phone;
+
+    private String extParam;
     /**
      * 标识,用于回调是确认订单
      */
@@ -28,12 +40,12 @@ public class SettlementDepositRecordTable extends BaseTable {
 
     private String currency;
 
+    private String bankCode;
+
     private Integer status;
 
     private String channelCode;
 
-    private String channelProperty;
-
     private String requestBody;
 
     private String callbackUrl;
@@ -56,8 +68,6 @@ public class SettlementDepositRecordTable extends BaseTable {
 
     private Integer callbackMerchantMaxRetryCount;
 
-    private String callbackMerchantBody;
-
     private Date callbackMerchantTime;
 
 }

+ 14 - 8
crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/SettlementWithdrawRecordTable.java

@@ -17,12 +17,26 @@ public class SettlementWithdrawRecordTable extends BaseTable {
 
     private String serial;
 
+    private Long login;
+
+    private String code;
+
+    private String name;
+
+    private String email;
+
+    private String phone;
+
+    private String extParam;
+
     private String requestSerial;
 
     private BigDecimal amount;
 
     private String currency;
 
+    private String bankCode;
+
     private String address;
 
     private String bankUname;
@@ -37,14 +51,8 @@ public class SettlementWithdrawRecordTable extends BaseTable {
 
     private String swiftCode;
 
-    private String cvv;
-
-    private String expiryMonth;
-
     private String channelCode;
 
-    private String channelProperty;
-
     private String requestBody;
 
     /**
@@ -72,8 +80,6 @@ public class SettlementWithdrawRecordTable extends BaseTable {
 
     private Integer callbackMerchantMaxRetryCount;
 
-    private String callbackMerchantBody;
-
     private Date callbackMerchantTime;
 
 }

+ 120 - 0
crm-model/src/main/java/com/crm/rely/backend/model/util/AESJsUtil.java

@@ -0,0 +1,120 @@
+package com.crm.rely.backend.model.util;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.util.Arrays;
+import java.util.Base64;
+
+public class AESJsUtil {
+
+    private static final String AES_CBC = "AES/CBC/PKCS5Padding";
+    private static final String SALTED_STR = "Salted__";
+
+    /**
+     * 解密(对应 CryptoJS.AES.decrypt)
+     */
+    public static String decrypt(String cipherTextBase64, String password) {
+        try {
+            byte[] cipherData = Base64.getDecoder().decode(cipherTextBase64);
+
+            // 校验 Salted__
+            byte[] saltHeader = Arrays.copyOfRange(cipherData, 0, 8);
+            String header = new String(saltHeader, StandardCharsets.US_ASCII);
+            if (!SALTED_STR.equals(header)) {
+                throw new IllegalArgumentException("Invalid CryptoJS AES format");
+            }
+
+            // 取 salt
+            byte[] salt = Arrays.copyOfRange(cipherData, 8, 16);
+            byte[] encrypted = Arrays.copyOfRange(cipherData, 16, cipherData.length);
+
+            // 生成 key + iv
+            byte[] keyAndIv = evpBytesToKey(32, 16, salt, password.getBytes(StandardCharsets.UTF_8));
+            byte[] key = Arrays.copyOfRange(keyAndIv, 0, 32);
+            byte[] iv = Arrays.copyOfRange(keyAndIv, 32, 48);
+
+            Cipher cipher = Cipher.getInstance(AES_CBC);
+            cipher.init(
+                    Cipher.DECRYPT_MODE,
+                    new SecretKeySpec(key, "AES"),
+                    new IvParameterSpec(iv)
+            );
+
+            byte[] decrypted = cipher.doFinal(encrypted);
+            return new String(decrypted, StandardCharsets.UTF_8);
+        } catch (Exception e) {
+
+        }
+        return null;
+    }
+
+    /**
+     * 加密(对应 CryptoJS.AES.encrypt) 兼容浏览器
+     */
+    public static String encrypt(String plainText, String password) {
+        try {
+            byte[] salt = new byte[8];
+            System.arraycopy(
+                    MessageDigest.getInstance("MD5")
+                            .digest(Long.toString(System.nanoTime()).getBytes()),
+                    0, salt, 0, 8
+            );
+
+            byte[] keyAndIv = evpBytesToKey(32, 16, salt, password.getBytes(StandardCharsets.UTF_8));
+            byte[] key = Arrays.copyOfRange(keyAndIv, 0, 32);
+            byte[] iv = Arrays.copyOfRange(keyAndIv, 32, 48);
+
+            Cipher cipher = Cipher.getInstance(AES_CBC);
+            cipher.init(
+                    Cipher.ENCRYPT_MODE,
+                    new SecretKeySpec(key, "AES"),
+                    new IvParameterSpec(iv)
+            );
+
+            byte[] encrypted = cipher.doFinal(plainText.getBytes(StandardCharsets.UTF_8));
+
+            byte[] result = new byte[16 + encrypted.length];
+            System.arraycopy(SALTED_STR.getBytes(), 0, result, 0, 8);
+            System.arraycopy(salt, 0, result, 8, 8);
+            System.arraycopy(encrypted, 0, result, 16, encrypted.length);
+            return URLEncoder.encode(Base64.getEncoder().encodeToString(result), StandardCharsets.UTF_8.name());
+        } catch (Exception e) {
+
+        }
+        return null;
+
+    }
+
+    /**
+     * OpenSSL EVP_BytesToKey(MD5)
+     */
+    private static byte[] evpBytesToKey(
+            int keyLen,
+            int ivLen,
+            byte[] salt,
+            byte[] password
+    ) throws Exception {
+
+        MessageDigest md = MessageDigest.getInstance("MD5");
+        byte[] keyAndIv = new byte[keyLen + ivLen];
+        byte[] previous = new byte[0];
+        int generated = 0;
+
+        while (generated < keyAndIv.length) {
+            md.reset();
+            md.update(previous);
+            md.update(password);
+            md.update(salt);
+            previous = md.digest();
+
+            int copyLen = Math.min(previous.length, keyAndIv.length - generated);
+            System.arraycopy(previous, 0, keyAndIv, generated, copyLen);
+            generated += copyLen;
+        }
+        return keyAndIv;
+    }
+}

+ 104 - 0
crm-model/src/main/java/com/crm/rely/backend/model/util/MapToEntityConverterUtil.java

@@ -0,0 +1,104 @@
+package com.crm.rely.backend.model.util;
+
+import com.alibaba.fastjson.JSON;
+import com.crm.rely.backend.core.exception.ServiceException;
+import com.crm.rely.backend.model.entity.settlement.vaultody.VaultodyDepositRequestEntity;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import jakarta.validation.ConstraintViolation;
+import jakarta.validation.Validation;
+import jakarta.validation.Validator;
+import jakarta.validation.ValidatorFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * @author gao
+ * @date 2026/4/29
+ */
+public class MapToEntityConverterUtil {
+
+    private static final ObjectMapper objectMapper;
+    private static final Validator validator;
+
+    static {
+        // 配置 ObjectMapper:忽略未知字段
+        objectMapper = new ObjectMapper();
+        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+        try (ValidatorFactory factory = Validation.buildDefaultValidatorFactory()) {
+            validator = factory.getValidator();
+        }
+    }
+
+    /**
+     * 从 Map 转换为实体并验证
+     */
+    public static <T> T convertAndValidate(Map<String, String> map, Class<T> clazz) {
+        T entity = objectMapper.convertValue(map, clazz);
+
+        Set<ConstraintViolation<T>> violations = validator.validate(entity);
+
+        if (!violations.isEmpty()) {
+            String errorMsg = violations.stream()
+                    .map(ConstraintViolation::getMessage)
+                    .collect(Collectors.joining("; "));
+            throw ServiceException.exception(errorMsg);
+//            throw new IllegalArgumentException("参数验证失败: " + errorMsg);
+        }
+
+        return entity;
+    }
+
+    /**
+     * 仅转换,不验证
+     */
+    public static <T> T convert(Map<String, String> map, Class<T> clazz) {
+        return objectMapper.convertValue(map, clazz);
+    }
+
+    /**
+     * 仅验证已有的实体对象
+     */
+    public static <T> void validate(T entity) {
+        Set<ConstraintViolation<T>> violations = validator.validate(entity);
+        if (!violations.isEmpty()) {
+            String errorMsg = violations.stream()
+                    .map(ConstraintViolation::getMessage)
+                    .collect(Collectors.joining("; "));
+            throw ServiceException.exception(errorMsg);
+        }
+    }
+
+    public static void main(String[] args) {
+        Map<String, String> params = new HashMap<>();
+        params.put("merchantId", "1");
+        params.put("code", "code");
+        params.put("name", "balanceTable.getName()");
+        params.put("email", "email");
+        params.put("phone", "phone");
+        params.put("extParam", "extParam");
+        params.put("serial", "orderNo");
+        params.put("amount", "12.00000");
+        params.put("currency", "balanceTable.getTransformCurrency()");
+        params.put("channelCode", "balanceTable.getRemittanceChannelCode()");
+        params.put("bankCode", "balanceTable.getBankCode()");
+        params.put("callbackUrl", "propertyEntity.getCallbackUrl()");
+        params.put("requestTime", String.valueOf(System.currentTimeMillis()));
+        params.put("bankName", "bankTable.getName()");
+        params.put("bankEnName", "bankTable.getEnName()");
+        params.put("bankCurrency", "bankTable.getCurrency()");
+        params.put("sign", "sign");
+        params.put("aa", "aa");
+        params.put("bb", "bb");
+        System.out.println(JSON.toJSONString(params));
+        VaultodyDepositRequestEntity depositRequest = MapToEntityConverterUtil.convertAndValidate(params, VaultodyDepositRequestEntity.class);
+        System.out.println(JSON.toJSONString(depositRequest));
+
+
+    }
+
+}

+ 32 - 4
crm-settlement/src/main/java/com/crm/settlement/controller/SettlementController.java

@@ -1,8 +1,13 @@
 package com.crm.settlement.controller;
 
 import com.crm.rely.backend.core.dto.base.BaseResultDto;
-import com.crm.rely.backend.model.entity.settlement.SettlementDepositEntity;
-import com.crm.rely.backend.model.entity.settlement.SettlementWithdrawEntity;
+import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
+import com.crm.rely.backend.model.dto.settlement.SettlementDepositDto;
+import com.crm.rely.backend.model.dto.settlement.SettlementWithdrawDto;
+import com.crm.rely.backend.model.entity.settlement.SettlementDepositListSearchEntity;
+import com.crm.rely.backend.model.entity.settlement.SettlementValidateDepositEntity;
+import com.crm.rely.backend.model.entity.settlement.SettlementValidateWithdrawEntity;
+import com.crm.rely.backend.model.entity.settlement.SettlementWithdrawListSearchEntity;
 import com.crm.settlement.service.SettlementService;
 import jakarta.validation.Valid;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -11,6 +16,9 @@ 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;
+import java.util.Map;
+
 @RestController
 @RequestMapping("/settlement")
 public class SettlementController {
@@ -18,14 +26,34 @@ public class SettlementController {
     @Autowired
     private SettlementService settlementService;
 
+    @PostMapping("/deposit")
+    public BaseResultDto deposit(@RequestBody Map<String, String> request) throws Exception {
+        return settlementService.deposit(request);
+    }
+
+    @PostMapping("/withdraw")
+    public BaseResultDto withdraw(@RequestBody Map<String, String> request) throws Exception {
+        return settlementService.withdraw(request);
+    }
+
     @PostMapping("/validate/deposit/order")
-    public BaseResultDto validateDepositOrder(@Valid @RequestBody SettlementDepositEntity entity) throws Exception {
+    public BaseResultDto validateDepositOrder(@Valid @RequestBody SettlementValidateDepositEntity entity) throws Exception {
         return settlementService.validateDepositOrder(entity);
     }
 
     @PostMapping("/validate/withdraw/order")
-    public BaseResultDto validateWithdrawOrder(@Valid @RequestBody SettlementWithdrawEntity request) throws Exception {
+    public BaseResultDto validateWithdrawOrder(@Valid @RequestBody SettlementValidateWithdrawEntity request) throws Exception {
         return settlementService.validateWithdrawOrder(request);
     }
 
+    @PostMapping("/deposit/search/list")
+    public BaseResultWithPagerDto<List<SettlementDepositDto>> depositSearchList(@RequestBody SettlementDepositListSearchEntity entity) throws Exception {
+        return settlementService.depositSearchList(entity);
+    }
+
+    @PostMapping("/withdraw/search/list")
+    public BaseResultWithPagerDto<List<SettlementWithdrawDto>> withdrawSearchList(@RequestBody SettlementWithdrawListSearchEntity entity) throws Exception {
+        return settlementService.withdrawSearchList(entity);
+    }
+
 }

+ 0 - 11
crm-settlement/src/main/java/com/crm/settlement/controller/VaultodyController.java

@@ -15,17 +15,6 @@ public class VaultodyController {
     @Autowired
     private VaultodyService vaultodyService;
 
-    @PostMapping("/deposit")
-    public BaseResultDto deposit(@Valid @RequestBody VaultodyDepositRequestEntity entity) throws Exception {
-        return vaultodyService.deposit(entity);
-    }
-
-    @PostMapping("/withdraw")
-    public BaseResultDto withdraw(
-            @Valid @RequestBody VaultodyWithdrawRequestEntity request) throws Exception {
-        return vaultodyService.withdraw(request);
-    }
-
     @PostMapping("/callback/deposit")
     public BaseResultDto depositCallback(@RequestBody String content, @RequestHeader("x-signature") String signature) throws Exception {
         try {

+ 6 - 0
crm-settlement/src/main/java/com/crm/settlement/dao/mapper/SettlementDepositRecordMapper.java

@@ -1,5 +1,6 @@
 package com.crm.settlement.dao.mapper;
 
+import com.crm.rely.backend.model.entity.settlement.SettlementDepositListSearchEntity;
 import com.crm.rely.backend.model.pojo.table.SettlementDepositRecordTable;
 import org.springframework.stereotype.Repository;
 
@@ -8,6 +9,11 @@ import java.util.List;
 @Repository
 public interface SettlementDepositRecordMapper {
 
+
+    List<SettlementDepositRecordTable> pageList(SettlementDepositListSearchEntity entity);
+
+    Integer countList(SettlementDepositListSearchEntity entity);
+
     /**
      * 获取可回调的记录
      */

+ 4 - 0
crm-settlement/src/main/java/com/crm/settlement/dao/mapper/SettlementWithdrawRecordMapper.java

@@ -1,5 +1,6 @@
 package com.crm.settlement.dao.mapper;
 
+import com.crm.rely.backend.model.entity.settlement.SettlementWithdrawListSearchEntity;
 import com.crm.rely.backend.model.pojo.table.SettlementWithdrawRecordTable;
 import org.springframework.stereotype.Repository;
 
@@ -14,4 +15,7 @@ public interface SettlementWithdrawRecordMapper {
     List<SettlementWithdrawRecordTable> getAllCallback();
 
 
+    Integer countList(SettlementWithdrawListSearchEntity entity);
+
+    List<SettlementWithdrawRecordTable> pageList(SettlementWithdrawListSearchEntity entity);
 }

+ 10 - 0
crm-settlement/src/main/java/com/crm/settlement/dao/repository/SettlementCallbackLogRepository.java

@@ -0,0 +1,10 @@
+package com.crm.settlement.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.SettlementCallbackLogTable;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface SettlementCallbackLogRepository extends BaseRepository<SettlementCallbackLogTable> {
+
+}

+ 2 - 0
crm-settlement/src/main/java/com/crm/settlement/dao/repository/SettlementDepositRecordRepository.java

@@ -16,4 +16,6 @@ public interface SettlementDepositRecordRepository extends BaseRepository<Settle
 
     SettlementDepositRecordTable findFirstByRequestSerialAndChannelCode(String requestSerial, String channelCode);
 
+    boolean existsByMerchantIdAndSerial(String merchantId, String serial);
+
 }

+ 2 - 0
crm-settlement/src/main/java/com/crm/settlement/dao/repository/SettlementWithdrawRecordRepository.java

@@ -16,4 +16,6 @@ public interface SettlementWithdrawRecordRepository extends BaseRepository<Settl
 
     SettlementWithdrawRecordTable findFirstByRequestSerialAndChannelCode(String requestSerial, String channelCode);
 
+    boolean existsByMerchantIdAndSerial(String merchantId, String serial);
+
 }

+ 9 - 0
crm-settlement/src/main/java/com/crm/settlement/service/SettlementLogService.java

@@ -0,0 +1,9 @@
+package com.crm.settlement.service;
+
+import com.crm.rely.backend.model.entity.settlement.log.SettlementCallbackLogAddEntity;
+
+public interface SettlementLogService {
+
+
+    void add(SettlementCallbackLogAddEntity entity);
+}

+ 18 - 5
crm-settlement/src/main/java/com/crm/settlement/service/SettlementService.java

@@ -1,16 +1,29 @@
 package com.crm.settlement.service;
 
 import com.crm.rely.backend.core.dto.base.BaseResultDto;
-import com.crm.rely.backend.core.exception.PayValidatedException;
-import com.crm.rely.backend.model.entity.settlement.SettlementDepositEntity;
-import com.crm.rely.backend.model.entity.settlement.SettlementWithdrawEntity;
+import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
+import com.crm.rely.backend.model.dto.settlement.SettlementDepositDto;
+import com.crm.rely.backend.model.dto.settlement.SettlementWithdrawDto;
+import com.crm.rely.backend.model.entity.settlement.SettlementDepositListSearchEntity;
+import com.crm.rely.backend.model.entity.settlement.SettlementValidateDepositEntity;
+import com.crm.rely.backend.model.entity.settlement.SettlementValidateWithdrawEntity;
+import com.crm.rely.backend.model.entity.settlement.SettlementWithdrawListSearchEntity;
+
+import java.util.List;
+import java.util.Map;
 
 public interface SettlementService {
 
 
-    BaseResultDto validateDepositOrder(SettlementDepositEntity entity) throws PayValidatedException;
+    BaseResultDto validateDepositOrder(SettlementValidateDepositEntity entity) throws Exception;
+
+    BaseResultDto validateWithdrawOrder(SettlementValidateWithdrawEntity entity) throws Exception;
+
+    BaseResultDto deposit(Map<String, String> request) throws Exception;
 
-    BaseResultDto validateWithdrawOrder(SettlementWithdrawEntity entity) throws PayValidatedException;
+    BaseResultDto withdraw(Map<String, String> request) throws Exception;
 
+    BaseResultWithPagerDto<List<SettlementDepositDto>> depositSearchList(SettlementDepositListSearchEntity entity) throws Exception;
 
+    BaseResultWithPagerDto<List<SettlementWithdrawDto>> withdrawSearchList(SettlementWithdrawListSearchEntity entity) throws Exception;
 }

+ 25 - 0
crm-settlement/src/main/java/com/crm/settlement/service/impl/SettlementLogServiceImpl.java

@@ -0,0 +1,25 @@
+package com.crm.settlement.service.impl;
+
+import com.crm.rely.backend.model.entity.settlement.log.SettlementCallbackLogAddEntity;
+import com.crm.rely.backend.model.pojo.table.SettlementCallbackLogTable;
+import com.crm.settlement.dao.repository.SettlementCallbackLogRepository;
+import com.crm.settlement.service.SettlementLogService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service
+public class SettlementLogServiceImpl implements SettlementLogService {
+
+    @Autowired
+    private SettlementCallbackLogRepository settlementCallbackLogRepository;
+
+    @Override
+    public void add(SettlementCallbackLogAddEntity entity) {
+        SettlementCallbackLogTable table = new SettlementCallbackLogTable();
+        BeanUtils.copyProperties(entity, table);
+        settlementCallbackLogRepository.save(table);
+    }
+}

+ 321 - 184
crm-settlement/src/main/java/com/crm/settlement/service/impl/SettlementServiceImpl.java

@@ -1,28 +1,48 @@
 package com.crm.settlement.service.impl;
 
 import com.alibaba.fastjson2.JSON;
-import com.alibaba.fastjson2.TypeReference;
+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.BaseResultWithPagerDto;
+import com.crm.rely.backend.core.dto.base.PageDto;
+import com.crm.rely.backend.core.entity.base.PageEntity;
 import com.crm.rely.backend.core.exception.PayValidatedException;
 import com.crm.rely.backend.core.exception.ServiceException;
-import com.crm.rely.backend.service.MqSendService;
-import com.crm.rely.backend.util.DateUtil;
-import com.crm.rely.backend.util.HttpUtil;
-import com.crm.rely.backend.util.MapUtil;
 import com.crm.rely.backend.model.constant.ConfigConstants;
-import com.crm.rely.backend.model.entity.settlement.SettlementDepositEntity;
-import com.crm.rely.backend.model.entity.settlement.SettlementWithdrawEntity;
+import com.crm.rely.backend.model.constant.SettlementConstant;
+import com.crm.rely.backend.model.dto.settlement.SettlementDepositDto;
+import com.crm.rely.backend.model.dto.settlement.SettlementValidateDto;
+import com.crm.rely.backend.model.dto.settlement.SettlementWithdrawDto;
+import com.crm.rely.backend.model.entity.base.MerchantPayInRequestEntity;
+import com.crm.rely.backend.model.entity.base.MerchantPayOutRequestEntity;
+import com.crm.rely.backend.model.entity.settlement.SettlementDepositListSearchEntity;
+import com.crm.rely.backend.model.entity.settlement.SettlementValidateDepositEntity;
+import com.crm.rely.backend.model.entity.settlement.SettlementValidateWithdrawEntity;
+import com.crm.rely.backend.model.entity.settlement.SettlementWithdrawListSearchEntity;
+import com.crm.rely.backend.model.entity.settlement.log.SettlementCallbackLogAddEntity;
+import com.crm.rely.backend.model.entity.settlement.vaultody.VaultodyDepositRequestEntity;
+import com.crm.rely.backend.model.entity.settlement.vaultody.VaultodyWithdrawRequestEntity;
 import com.crm.rely.backend.model.pojo.table.SettlementDepositRecordTable;
 import com.crm.rely.backend.model.pojo.table.SettlementWithdrawRecordTable;
+import com.crm.rely.backend.model.pojo.table.SysSettlementConfigTable;
+import com.crm.rely.backend.model.util.MapToEntityConverterUtil;
+import com.crm.rely.backend.service.MqSendService;
+import com.crm.rely.backend.util.FormatPage;
+import com.crm.rely.backend.util.HttpUtil;
+import com.crm.rely.backend.util.MapUtil;
 import com.crm.settlement.dao.mapper.SettlementDepositRecordMapper;
 import com.crm.settlement.dao.mapper.SettlementWithdrawRecordMapper;
 import com.crm.settlement.dao.repository.SettlementDepositRecordRepository;
 import com.crm.settlement.dao.repository.SettlementWithdrawRecordRepository;
+import com.crm.settlement.service.SettlementLogService;
 import com.crm.settlement.service.SettlementService;
+import com.crm.settlement.service.SysSettlementConfigService;
+import com.crm.settlement.service.VaultodyService;
 import com.crm.settlement.service.impl.base.BaseSettlementServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.jsoup.Connection;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jms.annotation.JmsListener;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -30,10 +50,8 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.math.BigDecimal;
+import java.util.*;
 
 @Slf4j
 @Service
@@ -48,6 +66,12 @@ public class SettlementServiceImpl extends BaseSettlementServiceImpl implements
     @Autowired
     private SettlementWithdrawRecordMapper settlementWithdrawRecordMapper;
     @Autowired
+    private SysSettlementConfigService sysSettlementConfigService;
+    @Autowired
+    private VaultodyService vaultodyService;
+    @Autowired
+    private SettlementLogService settlementLogService;
+    @Autowired
     private MqSendService mqSendService;
 
 
@@ -55,60 +79,235 @@ public class SettlementServiceImpl extends BaseSettlementServiceImpl implements
      * 验证入金订单
      */
     @Override
-    public BaseResultDto validateDepositOrder(SettlementDepositEntity entity) {
+    public BaseResultDto validateDepositOrder(SettlementValidateDepositEntity entity) {
         try {
             //验证时间
-            long time = DateUtil.getTimestampByZero() - entity.getRequestTime().getTime();
-            if ((time > (10 * 1000)) || (time < 0)) {
-                log.error("time out ,time:" + time);
+            Long requestTimestamp = entity.getRequestTime();
+            //验证时间
+            long serverTimestamp = System.currentTimeMillis();
+            long timeDiff = Math.abs(serverTimestamp - requestTimestamp);
+            if (timeDiff > 60000) {
+                log.error("time out :" + JSON.toJSONString(entity) + ",serverTime:" + serverTimestamp + ",requestTime:" + requestTimestamp + ",diff:" + timeDiff);
                 throw ServiceException.exception("Time out");
             }
 
             verifySign(entity.getSign(), getDepositSignString(entity), entity.getMerchantId());
             SettlementDepositRecordTable recordTable = settlementDepositRecordRepository.findFirstBySerialAndChannelCode(entity.getSerial(), entity.getChannelCode());
-            if (recordTable == null) {
+            if (recordTable == null || recordTable.getStatus() == null || recordTable.getStatus().equals(0)) {
                 return BaseResultDto.error();
             }
-            if (recordTable.getCallbackAmount().compareTo(entity.getCallbackAmount()) != 0
-                    || !recordTable.getCallbackCurrency().equals(entity.getCallbackCurrency())
-                    || !recordTable.getCallbackSerial().equals(entity.getCallbackSerial())
-                    || !recordTable.getStatus().equals(entity.getStatus())){
-                return BaseResultDto.error();
-            }
-        } catch (Exception e){
+            SettlementValidateDto dto = new SettlementValidateDto();
+            dto.setStatus(recordTable.getStatus());
+            return BaseResultDto.success(dto);
+        } catch (Exception e) {
             return BaseResultDto.error();
         }
-        return BaseResultDto.success();
     }
 
     /**
      * 验证出金订单
      */
     @Override
-    public BaseResultDto validateWithdrawOrder(SettlementWithdrawEntity entity) throws PayValidatedException {
+    public BaseResultDto validateWithdrawOrder(SettlementValidateWithdrawEntity entity) throws PayValidatedException {
         try {
             //验证时间
-            long time = DateUtil.getTimestampByZero() - entity.getRequestTime().getTime();
-            if ((time > (10 * 1000)) || (time < 0)) {
-                log.error("time out ,time:" + time);
+            Long requestTimestamp = entity.getRequestTime();
+            //验证时间
+            long serverTimestamp = System.currentTimeMillis();
+            long timeDiff = Math.abs(serverTimestamp - requestTimestamp);
+            if (timeDiff > 60000) {
+                log.error("time out :" + JSON.toJSONString(entity) + ",serverTime:" + serverTimestamp + ",requestTime:" + requestTimestamp + ",diff:" + timeDiff);
                 throw ServiceException.exception("Time out");
             }
 
             verifySign(entity.getSign(), getWithdrawSignString(entity), entity.getMerchantId());
             SettlementWithdrawRecordTable recordTable = settlementWithdrawRecordRepository.findFirstBySerialAndChannelCode(entity.getSerial(), entity.getChannelCode());
-            if (recordTable == null) {
-                return BaseResultDto.error();
-            }
-            if (recordTable.getCallbackAmount().compareTo(entity.getCallbackAmount()) != 0
-                    || !recordTable.getCallbackCurrency().equals(entity.getCallbackCurrency())
-                    || !recordTable.getCallbackSerial().equals(entity.getCallbackSerial())
-                    || !recordTable.getStatus().equals(entity.getStatus())){
+            if (recordTable == null || recordTable.getStatus() == null || recordTable.getStatus().equals(0)) {
                 return BaseResultDto.error();
             }
-        } catch (Exception e){
+            SettlementValidateDto dto = new SettlementValidateDto();
+            dto.setStatus(recordTable.getStatus());
+            return BaseResultDto.success(dto);
+        } catch (Exception e) {
             return BaseResultDto.error();
         }
-        return BaseResultDto.success();
+    }
+
+    @Override
+    public BaseResultDto deposit(Map<String, String> request) throws Exception {
+        MerchantPayInRequestEntity requestEntity = verifyDepositRequest(request);
+
+        String channelCode = requestEntity.getChannelCode();
+        switch (channelCode) {
+            case SettlementConstant.VAULTODY_PAY_KEY:
+                VaultodyDepositRequestEntity vaultodyDepositRequest = MapToEntityConverterUtil.convertAndValidate(request, VaultodyDepositRequestEntity.class);
+                return vaultodyService.deposit(vaultodyDepositRequest);
+            default:
+                throw ServiceException.exception("channel Not support");
+        }
+    }
+
+    @Override
+    public BaseResultDto withdraw(Map<String, String> request) throws Exception{
+        MerchantPayOutRequestEntity requestEntity = verifyWithdrawRequest(request);
+
+        String channelCode = requestEntity.getChannelCode();
+        switch (channelCode) {
+            case SettlementConstant.VAULTODY_PAY_REMIT:
+                VaultodyWithdrawRequestEntity vaultodyWithdrawRequest = MapToEntityConverterUtil.convertAndValidate(request, VaultodyWithdrawRequestEntity.class);
+                return vaultodyService.withdraw(vaultodyWithdrawRequest);
+            default:
+                throw ServiceException.exception("channel Not support");
+        }
+    }
+
+    @Override
+    public BaseResultWithPagerDto<List<SettlementDepositDto>> depositSearchList(SettlementDepositListSearchEntity entity) throws Exception {
+        String signString = getDepositlistSignString(entity);
+        verifySign(entity.getSign(), signString, entity.getMerchantId());
+        if (entity.getCurrent() != null && entity.getRow() != null){
+            PageEntity page = new PageEntity();
+            page.setCurrent(entity.getCurrent());
+            page.setRow(entity.getRow());
+            entity.setPage(page);
+        }
+        /*
+            获取总数
+         */
+        Integer count = settlementDepositRecordMapper.countList(entity);
+        PageDto pageDto = FormatPage.format(entity.getPage(), count);
+        if (count <= 0) {
+            if (count == null || count == 0) {
+                return BaseResultWithPagerDto.success(pageDto);
+            }
+        }
+        /*
+            获取列表
+         */
+        List<SettlementDepositRecordTable> depositRecordTables = settlementDepositRecordMapper.pageList(entity);
+        if (depositRecordTables == null || depositRecordTables.size() <= 0) {
+
+            throw new ServiceException(Constants.SYSTEM_ERROR);
+        }
+        List<SettlementDepositDto> depositDtos = new ArrayList<>(depositRecordTables.size());
+
+        for (SettlementDepositRecordTable depositRecordTable : depositRecordTables) {
+            SettlementDepositDto depositDto = depositTransform(depositRecordTable);
+            depositDtos.add(depositDto);
+        }
+        return BaseResultWithPagerDto.success(depositDtos, pageDto);
+    }
+
+    @Override
+    public BaseResultWithPagerDto<List<SettlementWithdrawDto>> withdrawSearchList(SettlementWithdrawListSearchEntity entity) throws Exception {
+        String signString = getWithdrawlistSignString(entity);
+        verifySign(entity.getSign(), signString, entity.getMerchantId());
+        if (entity.getCurrent() != null && entity.getRow() != null){
+            PageEntity page = new PageEntity();
+            page.setCurrent(entity.getCurrent());
+            page.setRow(entity.getRow());
+            entity.setPage(page);
+        }
+        /*
+            获取总数
+         */
+        Integer count = settlementWithdrawRecordMapper.countList(entity);
+        PageDto pageDto = FormatPage.format(entity.getPage(), count);
+        if (count <= 0) {
+            if (count == null || count == 0) {
+                return BaseResultWithPagerDto.success(pageDto);
+            }
+        }
+        /*
+            获取列表
+         */
+        List<SettlementWithdrawRecordTable> withdrawRecordTables = settlementWithdrawRecordMapper.pageList(entity);
+        if (withdrawRecordTables == null || withdrawRecordTables.size() <= 0) {
+
+            throw new ServiceException(Constants.SYSTEM_ERROR);
+        }
+        List<SettlementWithdrawDto> withdrawDtos = new ArrayList<>(withdrawRecordTables.size());
+
+        for (SettlementWithdrawRecordTable depositRecordTable : withdrawRecordTables) {
+            SettlementWithdrawDto depositDto = withdrawTransform(depositRecordTable);
+            withdrawDtos.add(depositDto);
+        }
+        return BaseResultWithPagerDto.success(withdrawDtos, pageDto);
+    }
+
+    private SettlementDepositDto depositTransform(SettlementDepositRecordTable depositRecordTable) {
+        SettlementDepositDto depositDto = new SettlementDepositDto();
+        BeanUtils.copyProperties(depositRecordTable, depositDto);
+        return depositDto;
+    }
+
+    private SettlementWithdrawDto withdrawTransform(SettlementWithdrawRecordTable withdrawRecordTable) {
+        SettlementWithdrawDto withdrawDto = new SettlementWithdrawDto();
+        BeanUtils.copyProperties(withdrawRecordTable, withdrawDto);
+        return withdrawDto;
+    }
+
+    /**
+     * 验证请求时间和金额
+     */
+    protected MerchantPayOutRequestEntity verifyWithdrawRequest(Map<String, String> request) throws ServiceException {
+        MerchantPayOutRequestEntity requestEntity = MapToEntityConverterUtil.convertAndValidate(request, MerchantPayOutRequestEntity.class);
+        String merchantId = requestEntity.getMerchantId();
+        BigDecimal amount = requestEntity.getAmount();
+        Long requestTimestamp = requestEntity.getRequestTime();
+        //验证时间
+        long serverTimestamp = System.currentTimeMillis();
+        long timeDiff = Math.abs(serverTimestamp - requestTimestamp);
+        if (timeDiff > 60000) {
+            log.error("time out :" + JSON.toJSONString(request) + ",serverTime:" + serverTimestamp + ",requestTime:" + requestTimestamp + ",diff:" + timeDiff);
+            throw ServiceException.exception("Time out");
+        }
+        // 验证金额
+        if (amount.compareTo(BigDecimal.ZERO) <= 0) {
+            throw ServiceException.exception("Invalid amount");
+        }
+        // 验证商户
+        SysSettlementConfigTable table = sysSettlementConfigService.getByCode(merchantId);
+        if (table == null || StringUtils.isEmpty(table.getValue())) {
+            throw ServiceException.exception("Merchant error");
+        }
+        // 验证订单
+        if (settlementWithdrawRecordRepository.existsByMerchantIdAndSerial(request.get("merchantId"), request.get("serial"))) {
+            throw ServiceException.exception("Duplicate order");
+        }
+        return requestEntity;
+    }
+
+
+    /**
+     * 验证请求时间和金额
+     */
+    protected MerchantPayInRequestEntity verifyDepositRequest(Map<String, String> request) throws ServiceException {
+        MerchantPayInRequestEntity requestEntity = MapToEntityConverterUtil.convertAndValidate(request, MerchantPayInRequestEntity.class);
+        String merchantId = requestEntity.getMerchantId();
+        BigDecimal amount = requestEntity.getAmount();
+        Long requestTimestamp = requestEntity.getRequestTime();
+        //验证时间
+        long serverTimestamp = System.currentTimeMillis();
+        long timeDiff = Math.abs(serverTimestamp - requestTimestamp);
+        if (timeDiff > 60000) {
+            log.error("time out :" + JSON.toJSONString(request) + ",serverTime:" + serverTimestamp + ",requestTime:" + requestTimestamp + ",diff:" + timeDiff);
+            throw ServiceException.exception("Time out");
+        }
+        // 验证金额
+        if (amount.compareTo(BigDecimal.ZERO) <= 0) {
+            throw ServiceException.exception("Invalid amount");
+        }
+        // 验证商户
+        SysSettlementConfigTable table = sysSettlementConfigService.getByCode(merchantId);
+        if (table == null || StringUtils.isEmpty(table.getValue())) {
+            throw ServiceException.exception("Merchant error");
+        }
+        // 验证订单
+        if (settlementDepositRecordRepository.existsByMerchantIdAndSerial(request.get("merchantId"), request.get("serial"))) {
+            throw ServiceException.exception("Duplicate order");
+        }
+        return requestEntity;
     }
 
     @Transactional(rollbackFor = Exception.class)
@@ -119,16 +318,21 @@ public class SettlementServiceImpl extends BaseSettlementServiceImpl implements
 
         SettlementDepositRecordTable table = settlementDepositRecordRepository.findFirstById(recordTable.getId());
 
-        if (table == null){
+        if (table == null) {
             log.error("DEPOSIT_CALLBACK SettlementDepositRecordTable is null");
             return;
         }
+        // 判断三方回调状态
+        if (!table.getCallbackStatus()) {
+            log.info("DEPOSIT_CALLBACK: callbackStatus is Failed ");
+            return;
+        }
         // 判断状态
-        if (table.getCallbackMerchantStatus().equals(1)){
+        if (table.getCallbackMerchantStatus().equals(1)) {
             log.info("DEPOSIT_CALLBACK: callbackMerchantStatus is Success ");
             return;
         }
-        if (table.getCallbackMerchantCount() >= table.getCallbackMerchantMaxRetryCount()){
+        if (table.getCallbackMerchantCount() >= table.getCallbackMerchantMaxRetryCount()) {
             log.info("DEPOSIT_CALLBACK: callbackMerchantCount is max retry count");
             return;
         }
@@ -136,12 +340,11 @@ public class SettlementServiceImpl extends BaseSettlementServiceImpl implements
         String callbackUrl = table.getCallbackUrl();
         Map<String, String> params = new HashMap<>();
         params.put("serial", table.getSerial());
+        params.put("login", String.valueOf(table.getLogin()));
         params.put("channelCode", table.getChannelCode());
         params.put("callbackAmount", table.getCallbackAmount().stripTrailingZeros().toPlainString());
         params.put("callbackCurrency", table.getCallbackCurrency());
         params.put("callbackSerial", table.getCallbackSerial());
-        params.put("status", String.valueOf(table.getStatus()));
-        String callbackMerchantBody = JSON.toJSONString(params);
         String sign = getSign(params, table.getMerchantId());
         params.put("sign", sign);
 
@@ -159,14 +362,24 @@ public class SettlementServiceImpl extends BaseSettlementServiceImpl implements
         } catch (Exception e) {
             log.error("DEPOSIT_CALLBACK, Request URL: {}, data:{}", callbackUrl, callbackContent, e);
             table.setCallbackMerchantStatus(2);
+        } finally {
+            SettlementCallbackLogAddEntity addEntity = new SettlementCallbackLogAddEntity();
+            addEntity.setMerchantId(table.getMerchantId());
+            addEntity.setSerial(table.getSerial());
+            addEntity.setAmount(table.getCallbackAmount());
+            addEntity.setChannelCode(table.getChannelCode());
+            addEntity.setCallbackUrl(callbackUrl);
+            addEntity.setCallbackData(callbackContent);
+            addEntity.setAddTime(new Date());
+            addEntity.setNote("入金回调");
+            settlementLogService.add(addEntity);
         }
 
-        table.setCallbackMerchantBody(callbackMerchantBody);
         table.setCallbackMerchantCount(table.getCallbackMerchantCount() + 1);
         table.setCallbackMerchantTime(new Date());
         settlementDepositRecordRepository.save(table);
-        if (table.getCallbackMerchantStatus().equals(2) && table.getCallbackMerchantCount() < table.getCallbackMerchantMaxRetryCount()){
-            mqSendService.send(ConfigConstants.DEPOSIT_RETRY_CALLBACK, table , 3 * 60 * 1000);
+        if (table.getCallbackMerchantStatus().equals(2) && table.getCallbackMerchantCount() < table.getCallbackMerchantMaxRetryCount()) {
+            mqSendService.send(ConfigConstants.DEPOSIT_CALLBACK, table, 3 * 60 * 1000);
         }
     }
 
@@ -179,16 +392,16 @@ public class SettlementServiceImpl extends BaseSettlementServiceImpl implements
 
         SettlementWithdrawRecordTable table = settlementWithdrawRecordRepository.findFirstById(withdrawRecordTable.getId());
 
-        if (table == null){
+        if (table == null) {
             log.error("WITHDRAW_CALLBACK SettlementDepositRecordTable is null");
             return;
         }
         // 判断状态
-        if (table.getCallbackMerchantStatus().equals(1)){
+        if (table.getCallbackMerchantStatus().equals(1)) {
             log.info("WITHDRAW_CALLBACK: callbackMerchantStatus is Success ");
             return;
         }
-        if (table.getCallbackMerchantCount() >= table.getCallbackMerchantMaxRetryCount()){
+        if (table.getCallbackMerchantCount() >= table.getCallbackMerchantMaxRetryCount()) {
             log.info("WITHDRAW_CALLBACK: callbackMerchantCount is max retry count");
             return;
         }
@@ -196,126 +409,11 @@ public class SettlementServiceImpl extends BaseSettlementServiceImpl implements
         String callbackUrl = table.getCallbackUrl();
         Map<String, String> params = new HashMap<>();
         params.put("serial", table.getSerial());
+        params.put("login", String.valueOf(table.getLogin()));
         params.put("channelCode", table.getChannelCode());
         params.put("callbackAmount", table.getCallbackAmount().stripTrailingZeros().toPlainString());
         params.put("callbackCurrency", table.getCallbackCurrency());
         params.put("callbackSerial", table.getCallbackSerial());
-        params.put("status", String.valueOf(table.getStatus()));
-        String callbackMerchantBody = JSON.toJSONString(params);
-        String sign = getSign(params, table.getMerchantId());
-        params.put("sign", sign);
-
-        String callbackContent = JSON.toJSONString(params);
-        try {
-            Connection.Response response = HttpUtil.post(callbackUrl, callbackContent);
-            //打印请求日志
-            log.info("WITHDRAW_CALLBACK Request URL: {},data:{},response body:{}", callbackUrl, callbackContent, response.body());
-            BaseResultDto requestEntity = JSON.parseObject(response.body(), BaseResultDto.class);
-            if (requestEntity == null || requestEntity.getCode() != 200) {
-                table.setCallbackMerchantStatus(2);
-            } else {
-                table.setCallbackMerchantStatus(1);
-            }
-        } catch (Exception e) {
-            log.error("WITHDRAW_CALLBACK, Request URL: {}, data:{}", callbackUrl, callbackContent, e);
-            table.setCallbackMerchantStatus(2);
-        }
-
-        table.setCallbackMerchantBody(callbackMerchantBody);
-        table.setCallbackMerchantCount(table.getCallbackMerchantCount() + 1);
-        table.setCallbackMerchantTime(new Date());
-        settlementWithdrawRecordRepository.save(table);
-        if (table.getCallbackMerchantStatus().equals(2) && table.getCallbackMerchantCount() < table.getCallbackMerchantMaxRetryCount()){
-            mqSendService.send(ConfigConstants.WITHDRAW_RETRY_CALLBACK, table , 3 * 60 * 1000);
-        }
-    }
-
-    @Transactional(rollbackFor = Exception.class)
-    @JmsListener(destination = ConfigConstants.DEPOSIT_RETRY_CALLBACK)
-    public void depositRetryCallback(String content) throws Exception {
-        log.info("DEPOSIT_RETRY_CALLBACK: content:" + content);
-        SettlementDepositRecordTable table = JSON.parseObject(content, SettlementDepositRecordTable.class);
-
-        if (table == null){
-            log.error("DEPOSIT_RETRY_CALLBACK SettlementDepositRecordTable is null");
-            return;
-        }
-        // 判断状态
-        if (table.getCallbackMerchantStatus().equals(1)){
-            log.info("DEPOSIT_RETRY_CALLBACK: callbackMerchantStatus is Success , serial:{}", table.getSerial());
-            return;
-        }
-        if (table.getCallbackMerchantCount() >= table.getCallbackMerchantMaxRetryCount()){
-            log.info("DEPOSIT_RETRY_CALLBACK: callbackMerchantCount is max retry count, serial:{}", table.getSerial());
-            return;
-        }
-
-        String callbackUrl = table.getCallbackUrl();
-        String body = table.getCallbackMerchantBody();
-
-        if (StringUtils.isEmpty(callbackUrl) || StringUtils.isEmpty(body)){
-            log.error("DEPOSIT_RETRY_CALLBACK: callbackUrl or callbackMerchantBody is null , serial:{}", table.getSerial());
-            return;
-        }
-
-        Map<String, String> params = JSON.parseObject(body, new TypeReference<Map<String, String>>(){});
-        String sign = getSign(params, table.getMerchantId());
-        params.put("sign", sign);
-
-        String callbackContent = JSON.toJSONString(params);
-        try {
-            Connection.Response response = HttpUtil.post(callbackUrl, callbackContent);
-            //打印请求日志
-            log.info("DEPOSIT_RETRY_CALLBACK Request URL: {},data:{},response body:{}", callbackUrl, callbackContent, response.body());
-            BaseResultDto requestEntity = JSON.parseObject(response.body(), BaseResultDto.class);
-            if (requestEntity == null || requestEntity.getCode() != 200) {
-                table.setCallbackMerchantStatus(2);
-            } else {
-                table.setCallbackMerchantStatus(1);
-            }
-        } catch (Exception e) {
-            log.error("DEPOSIT_RETRY_CALLBACK, Request URL: {}, data:{}", callbackUrl, callbackContent, e);
-            table.setCallbackMerchantStatus(2);
-        }
-
-        table.setCallbackMerchantCount(table.getCallbackMerchantCount() + 1);
-        table.setCallbackMerchantTime(new Date());
-        settlementDepositRecordRepository.save(table);
-        if (table.getCallbackMerchantStatus().equals(2) && table.getCallbackMerchantCount() < table.getCallbackMerchantMaxRetryCount()){
-            mqSendService.send(ConfigConstants.DEPOSIT_RETRY_CALLBACK, table , 3 * 60 * 1000);
-        }
-    }
-
-
-    @Transactional(rollbackFor = Exception.class)
-    @JmsListener(destination = ConfigConstants.WITHDRAW_RETRY_CALLBACK)
-    public void withdrawRetryCallback(String content) throws Exception {
-        log.info("WITHDRAW_RETRY_CALLBACK: content:" + content);
-        SettlementWithdrawRecordTable table = JSON.parseObject(content, SettlementWithdrawRecordTable.class);
-
-        if (table == null){
-            log.error("WITHDRAW_RETRY_CALLBACK SettlementDepositRecordTable is null");
-            return;
-        }
-        // 判断状态
-        if (table.getCallbackMerchantStatus().equals(1)){
-            log.info("WITHDRAW_RETRY_CALLBACK: callbackMerchantStatus is Success ");
-            return;
-        }
-        if (table.getCallbackMerchantCount() >= table.getCallbackMerchantMaxRetryCount()){
-            log.info("WITHDRAW_RETRY_CALLBACK: callbackMerchantCount is max retry count");
-            return;
-        }
-
-        String callbackUrl = table.getCallbackUrl();
-        String body = table.getCallbackMerchantBody();
-
-        if (StringUtils.isEmpty(callbackUrl) || StringUtils.isEmpty(body)){
-            log.error("WITHDRAW_RETRY_CALLBACK: callbackUrl or callbackMerchantBody is null , serial:{}", table.getSerial());
-            return;
-        }
-
-        Map<String, String> params = JSON.parseObject(body, new TypeReference<Map<String, String>>(){});
         String sign = getSign(params, table.getMerchantId());
         params.put("sign", sign);
 
@@ -333,13 +431,25 @@ public class SettlementServiceImpl extends BaseSettlementServiceImpl implements
         } catch (Exception e) {
             log.error("WITHDRAW_CALLBACK, Request URL: {}, data:{}", callbackUrl, callbackContent, e);
             table.setCallbackMerchantStatus(2);
+        } finally {
+            SettlementCallbackLogAddEntity addEntity = new SettlementCallbackLogAddEntity();
+            addEntity.setMerchantId(table.getMerchantId());
+            addEntity.setSerial(table.getSerial());
+            addEntity.setAmount(table.getCallbackAmount());
+            addEntity.setChannelCode(table.getChannelCode());
+            addEntity.setCallbackUrl(callbackUrl);
+            addEntity.setCallbackData(callbackContent);
+            addEntity.setAddTime(new Date());
+            addEntity.setNote("入金回调");
+            settlementLogService.add(addEntity);
         }
 
+//        table.setCallbackMerchantBody(callbackMerchantBody);
         table.setCallbackMerchantCount(table.getCallbackMerchantCount() + 1);
         table.setCallbackMerchantTime(new Date());
         settlementWithdrawRecordRepository.save(table);
-        if (table.getCallbackMerchantStatus().equals(2) && table.getCallbackMerchantCount() < table.getCallbackMerchantMaxRetryCount()){
-            mqSendService.send(ConfigConstants.WITHDRAW_RETRY_CALLBACK, table , 3 * 60 * 1000);
+        if (table.getCallbackMerchantStatus().equals(2) && table.getCallbackMerchantCount() < table.getCallbackMerchantMaxRetryCount()) {
+            mqSendService.send(ConfigConstants.WITHDRAW_CALLBACK, table, 3 * 60 * 1000);
         }
     }
 
@@ -353,44 +463,71 @@ public class SettlementServiceImpl extends BaseSettlementServiceImpl implements
         log.info("scheduleCallback start");
         List<SettlementDepositRecordTable> depositRecordTables = settlementDepositRecordMapper.getAllCallback();
         List<SettlementWithdrawRecordTable> withdrawRecordTables = settlementWithdrawRecordMapper.getAllCallback();
-        if (!CollectionUtils.isEmpty(depositRecordTables)){
+        if (!CollectionUtils.isEmpty(depositRecordTables)) {
             log.info("scheduleCallback: depositRecordTables size:{}", depositRecordTables.size());
-            for (SettlementDepositRecordTable table : depositRecordTables){
-                mqSendService.send(ConfigConstants.DEPOSIT_RETRY_CALLBACK, table);
+            for (SettlementDepositRecordTable table : depositRecordTables) {
+                mqSendService.send(ConfigConstants.DEPOSIT_CALLBACK, table);
             }
         }
-        if (!CollectionUtils.isEmpty(withdrawRecordTables)){
+        if (!CollectionUtils.isEmpty(withdrawRecordTables)) {
             log.info("scheduleCallback: withdrawRecordTables size:{}", withdrawRecordTables.size());
-            for (SettlementWithdrawRecordTable table : withdrawRecordTables){
-                mqSendService.send(ConfigConstants.WITHDRAW_RETRY_CALLBACK, table);
+            for (SettlementWithdrawRecordTable table : withdrawRecordTables) {
+                mqSendService.send(ConfigConstants.WITHDRAW_CALLBACK, table);
             }
         }
         log.info("scheduleCallback end");
     }
 
-    private String getDepositSignString(SettlementDepositEntity entity) {
+    private String getDepositSignString(SettlementValidateDepositEntity entity) {
+        Map<String, String> map = new HashMap<>();
+        map.put("merchantId", entity.getMerchantId());
+        map.put("channelCode", entity.getChannelCode());
+        map.put("serial", entity.getSerial());
+        map.put("requestTime", String.valueOf(entity.getRequestTime()));
+        return MapUtil.getStringSortByKey(map);
+    }
+
+    private String getWithdrawSignString(SettlementValidateWithdrawEntity entity) {
         Map<String, String> map = new HashMap<>();
         map.put("merchantId", entity.getMerchantId());
         map.put("channelCode", entity.getChannelCode());
         map.put("serial", entity.getSerial());
-        map.put("callbackAmount", entity.getCallbackAmount().stripTrailingZeros().toPlainString());
-        map.put("callbackCurrency", entity.getCallbackCurrency());
-        map.put("callbackSerial", entity.getCallbackSerial());
-        map.put("status", String.valueOf(entity.getStatus()));
-        map.put("requestTime", DateUtil.formatTime(entity.getRequestTime()));
+        map.put("requestTime", String.valueOf(entity.getRequestTime()));
         return MapUtil.getStringSortByKey(map);
     }
 
-    private String getWithdrawSignString(SettlementWithdrawEntity entity) {
+    private String getDepositlistSignString(SettlementDepositListSearchEntity entity) {
         Map<String, String> map = new HashMap<>();
         map.put("merchantId", entity.getMerchantId());
+        map.put("name", entity.getName());
+        map.put("email", entity.getEmail());
+        map.put("serial", entity.getSerial());
+        map.put("login", String.valueOf(entity.getLogin()));
         map.put("channelCode", entity.getChannelCode());
+        map.put("callbackMerchantStatus", String.valueOf(entity.getCallbackMerchantStatus()));
+        map.put("startDate", String.valueOf(entity.getStartDate()));
+        map.put("endDate", String.valueOf(entity.getEndDate()));
+        map.put("current", String.valueOf(entity.getCurrent()));
+        map.put("row", String.valueOf(entity.getRow()));
+        map.put("requestTime", String.valueOf(entity.getRequestTime()));
+        return MapUtil.getStringSortByKey(map);
+
+    }
+
+    private String getWithdrawlistSignString(SettlementWithdrawListSearchEntity entity) {
+        Map<String, String> map = new HashMap<>();
+        map.put("merchantId", entity.getMerchantId());
+        map.put("name", entity.getName());
+        map.put("email", entity.getEmail());
         map.put("serial", entity.getSerial());
-        map.put("callbackAmount", entity.getCallbackAmount().stripTrailingZeros().toPlainString());
-        map.put("callbackCurrency", entity.getCallbackCurrency());
-        map.put("callbackSerial", entity.getCallbackSerial());
-        map.put("status", String.valueOf(entity.getStatus()));
-        map.put("requestTime", DateUtil.formatTime(entity.getRequestTime()));
+        map.put("login", String.valueOf(entity.getLogin()));
+        map.put("channelCode", entity.getChannelCode());
+        map.put("callbackMerchantStatus", String.valueOf(entity.getCallbackMerchantStatus()));
+        map.put("startDate", String.valueOf(entity.getStartDate()));
+        map.put("endDate", String.valueOf(entity.getEndDate()));
+        map.put("current", String.valueOf(entity.getCurrent()));
+        map.put("row", String.valueOf(entity.getRow()));
+        map.put("requestTime", String.valueOf(entity.getRequestTime()));
         return MapUtil.getStringSortByKey(map);
     }
 

+ 34 - 28
crm-settlement/src/main/java/com/crm/settlement/service/impl/VaultodyServiceImpl.java

@@ -9,6 +9,7 @@ import com.crm.rely.backend.core.exception.ServiceException;
 import com.crm.rely.backend.core.pojo.table.SysConfigTable;
 import com.crm.rely.backend.model.entity.settlement.vaultody.callback.*;
 import com.crm.rely.backend.model.pojo.table.*;
+import com.crm.rely.backend.model.util.AESJsUtil;
 import com.crm.rely.backend.service.MqSendService;
 import com.crm.rely.backend.service.RedisService;
 import com.crm.rely.backend.util.HAMCSHA256Util;
@@ -72,16 +73,18 @@ public class VaultodyServiceImpl extends BaseSettlementServiceImpl implements Va
     @Override
     @Transactional(rollbackFor = Exception.class)
     public BaseResultDto deposit(VaultodyDepositRequestEntity request) throws Exception {
-        verifyRequestTimeAndAmount(request);
         String signString = getSignString(request);
         verifySign(request.getSign(), signString, request.getMerchantId());
 
         SysRemittanceChannelTable channelTable = getPayChannel(SettlementConstant.VAULTODY_PAY_KEY);
         VaultodyPayPropertyEntity property = getPayProperty(channelTable, VaultodyPayPropertyEntity.class);
         String address = reallocationAddress(request, property);
+        String url = String.format(property.getAddressUrl(), address, property.getSuccessUrl(),
+                String.valueOf(request.getAmount()), request.getCurrency(),
+                request.getBankName(), request.getBankEnName());
         // 保存记录
-        saveDepositRecord(request, channelTable.getProperty(), address);
-        return BaseResultDto.success(address);
+        saveDepositRecord(request, address);
+        return BaseResultDto.success(Constants.SUCCESS, AESJsUtil.encrypt(url, property.getDecryptKey()));
     }
 
     /**
@@ -142,7 +145,7 @@ public class VaultodyServiceImpl extends BaseSettlementServiceImpl implements Va
             log.error("Vaultody通知回调:addressTable为空,{}", content);
             return BaseResultDto.error();
         }
-        SettlementDepositRecordTable recordTable = settlementDepositRecordRepository.findFirstByRequestSerialAndChannelCode(address, SettlementConstant.VAULTODY_PAY_KEY);
+        SettlementDepositRecordTable recordTable = settlementDepositRecordRepository.findFirstBySerialAndChannelCode(addressTable.getSerial(), SettlementConstant.VAULTODY_PAY_KEY);
 
         if (recordTable == null || recordTable.getId() == null) {
             log.error("Vaultody通知回调:未找到对应的请求记录,{}", content);
@@ -215,15 +218,14 @@ public class VaultodyServiceImpl extends BaseSettlementServiceImpl implements Va
     @Override
     @Transactional(rollbackFor = Exception.class)
     public BaseResultDto withdraw(VaultodyWithdrawRequestEntity request) throws Exception {
-        verifyRequestTimeAndAmount(request);
         String signString = getWithdrawSignString(request);
         verifySign(request.getSign(), signString, request.getMerchantId());
 
         SysRemitChannelTable withdrawChannel = getWithdrawChannel(request.getChannelCode());
         VaultodyPayWithdrawPropertyEntity property = getWithdrawPayProperty(withdrawChannel, VaultodyPayWithdrawPropertyEntity.class);
         String requestId = createWithdraw(request, property);
-        saveWithdrawRecord(request, withdrawChannel.getProperty(), requestId);
-        return BaseResultDto.success(requestId);
+        saveWithdrawRecord(request, requestId);
+        return BaseResultDto.success(Constants.SUCCESS, requestId);
     }
 
     @Override
@@ -359,7 +361,7 @@ public class VaultodyServiceImpl extends BaseSettlementServiceImpl implements Va
     @Transactional(rollbackFor = Exception.class)
     public String getAddress(VaultodyPayPropertyEntity propertyEntity, VaultodyDepositRequestEntity request) throws Exception {
         String requestPath = getPath(propertyEntity.getAddressPathTemplate(), propertyEntity.getVaultId(),
-                request.getCurrency(),
+                request.getBankCode().split("_")[0],
                 propertyEntity.getNetwork());
         String apiKey = propertyEntity.getApiKey();
         String apiSecret = propertyEntity.getApiSecret();
@@ -419,11 +421,11 @@ public class VaultodyServiceImpl extends BaseSettlementServiceImpl implements Va
 
     private String createWithdraw(VaultodyWithdrawRequestEntity entity, VaultodyPayWithdrawPropertyEntity propertyEntity) throws Exception {
         String blockchain = null;
-        if (entity.getCurrency().contains("-")) {
-            blockchain = entity.getCurrency().split("-")[0];
+        if (entity.getBankCode().contains("-")) {
+            blockchain = entity.getBankCode().split("-")[0];
         }
         if (StringUtils.isEmpty(blockchain)) {
-            blockchain = entity.getCurrency();
+            blockchain = entity.getBankCode();
         }
         String requestPath = getPath(propertyEntity.getCreateTokenTransactionPathTemplate(),
                 propertyEntity.getVaultId(),
@@ -499,18 +501,24 @@ public class VaultodyServiceImpl extends BaseSettlementServiceImpl implements Va
      * 保存记录
      */
     @Transactional(rollbackFor = Exception.class)
-    public void saveDepositRecord(VaultodyDepositRequestEntity request, String property, String address) {
+    public void saveDepositRecord(VaultodyDepositRequestEntity request, String address) {
         SysConfigTable configTable = sysConfigService.getByCode(ConfigConstants.CALLBACK_MAX_RETRY_COUNT);
         Integer maxRetryCount = Integer.parseInt(configTable.getValue());
         SettlementDepositRecordTable table = new SettlementDepositRecordTable();
+        table.setCode(request.getCode());
+        table.setName(request.getName());
+        table.setEmail(request.getEmail());
+        table.setPhone(request.getPhone());
+        table.setExtParam(request.getExtParam());
+        table.setBankCode(request.getBankCode());
         table.setMerchantId(request.getMerchantId());
         table.setSerial(request.getSerial());
+        table.setLogin(request.getLogin());
         table.setRequestSerial(address);
         table.setAmount(request.getAmount());
         table.setCurrency(request.getCurrency());
         table.setStatus(0);
         table.setChannelCode(request.getChannelCode());
-        table.setChannelProperty(property);
         table.setRequestBody(JSON.toJSONString(request));
         table.setCallbackUrl(request.getCallbackUrl());
         table.setCallbackStatus(false);
@@ -522,7 +530,7 @@ public class VaultodyServiceImpl extends BaseSettlementServiceImpl implements Va
     }
 
     @Transactional(rollbackFor = Exception.class)
-    public void saveWithdrawRecord(VaultodyWithdrawRequestEntity request, String property, String requestId) {
+    public void saveWithdrawRecord(VaultodyWithdrawRequestEntity request, String requestId) {
         String blockchain = null;
         if (request.getCurrency().contains("-")) {
             blockchain = request.getCurrency().split("-")[0];
@@ -533,8 +541,15 @@ public class VaultodyServiceImpl extends BaseSettlementServiceImpl implements Va
         SysConfigTable configTable = sysConfigService.getByCode(ConfigConstants.CALLBACK_MAX_RETRY_COUNT);
         Integer maxRetryCount = Integer.parseInt(configTable.getValue());
         SettlementWithdrawRecordTable table = new SettlementWithdrawRecordTable();
+        table.setCode(request.getCode());
+        table.setName(request.getName());
+        table.setEmail(request.getEmail());
+        table.setPhone(request.getPhone());
+        table.setExtParam(request.getExtParam());
+        table.setBankCode(request.getBankCode());
         table.setMerchantId(request.getMerchantId());
         table.setSerial(request.getSerial());
+        table.setLogin(request.getLogin());
         table.setRequestSerial(requestId);
         table.setAmount(request.getAmount());
         table.setCurrency(blockchain);
@@ -545,10 +560,7 @@ public class VaultodyServiceImpl extends BaseSettlementServiceImpl implements Va
         table.setBankBranchName(request.getBankBranchName());
         table.setBankAddr(request.getBankAddr());
         table.setSwiftCode(request.getSwiftCode());
-        table.setCvv(request.getCvv());
-        table.setExpiryMonth(request.getExpiryMonth());
         table.setChannelCode(request.getChannelCode());
-        table.setChannelProperty(property);
         table.setRequestBody(JSON.toJSONString(request));
         table.setStatus(0);
         table.setCallbackUrl(request.getCallbackUrl());
@@ -561,21 +573,15 @@ public class VaultodyServiceImpl extends BaseSettlementServiceImpl implements Va
     }
 
     private String getSignString(VaultodyDepositRequestEntity entity) {
-        Map<String, String> map = getBaseSignString(entity);
+        Map<String, String> map = getBaseSignMap(entity);
+        map.put("bankName", entity.getBankName());
+        map.put("bankEnName", entity.getBankEnName());
+        map.put("bankCurrency", entity.getBankCurrency());
         return MapUtil.getStringSortByKey(map);
     }
 
     private String getWithdrawSignString(VaultodyWithdrawRequestEntity entity) {
-        Map<String, String> map = getBaseSignString(entity);
-        map.put("address", entity.getAddress());
-        map.put("bankUname", entity.getBankUname());
-        map.put("bankCardNum", entity.getBankCardNum());
-        map.put("bankName", entity.getBankName());
-        map.put("bankBranchName", entity.getBankBranchName());
-        map.put("bankAddr", entity.getBankAddr());
-        map.put("swiftCode", entity.getSwiftCode());
-        map.put("cvv", entity.getCvv());
-        map.put("expiryMonth", entity.getExpiryMonth());
+        Map<String, String> map = getBaseWithdrawSignMap(entity);
         return MapUtil.getStringSortByKey(map);
     }
 

+ 39 - 24
crm-settlement/src/main/java/com/crm/settlement/service/impl/base/BaseSettlementServiceImpl.java

@@ -4,17 +4,17 @@ import com.alibaba.fastjson2.JSON;
 import com.crm.rely.backend.core.constant.Constants;
 import com.crm.rely.backend.core.exception.ServiceException;
 import com.crm.rely.backend.core.pojo.table.SysConfigTable;
-import com.crm.rely.backend.util.AESUtil;
-import com.crm.rely.backend.util.DateUtil;
-import com.crm.rely.backend.util.MapUtil;
-import com.crm.rely.backend.util.SignUtil;
 import com.crm.rely.backend.model.constant.ConfigConstants;
 import com.crm.rely.backend.model.constant.SettlementConstant;
-import com.crm.rely.backend.model.entity.base.SettlementBaseEntity;
+import com.crm.rely.backend.model.entity.base.MerchantPayInRequestEntity;
+import com.crm.rely.backend.model.entity.base.MerchantPayOutRequestEntity;
 import com.crm.rely.backend.model.entity.property.SettlementPropertyEntity;
 import com.crm.rely.backend.model.pojo.table.SysRemitChannelTable;
 import com.crm.rely.backend.model.pojo.table.SysRemittanceChannelTable;
 import com.crm.rely.backend.model.pojo.table.SysSettlementConfigTable;
+import com.crm.rely.backend.util.AESUtil;
+import com.crm.rely.backend.util.MapUtil;
+import com.crm.rely.backend.util.SignUtil;
 import com.crm.settlement.service.SysConfigService;
 import com.crm.settlement.service.SysRemitChannelService;
 import com.crm.settlement.service.SysRemittanceChannelService;
@@ -23,7 +23,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.math.BigDecimal;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -154,22 +153,6 @@ public class BaseSettlementServiceImpl {
         }
     }
 
-    /**
-     * 验证请求时间和金额
-     */
-    protected void verifyRequestTimeAndAmount(SettlementBaseEntity entity) throws ServiceException {
-        //验证时间
-        long time = DateUtil.getTimestampByZero() - entity.getRequestTime().getTime();
-        if ((time > (10 * 1000)) || (time < 0)) {
-            log.error("time out ,time:" + time);
-            throw ServiceException.exception("Time out");
-        }
-        // 验证金额
-        if (entity.getAmount() == null || entity.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
-            throw ServiceException.exception("Invalid amount");
-        }
-    }
-
     /**
      * 获取签名
      */
@@ -181,16 +164,48 @@ public class BaseSettlementServiceImpl {
         return SignUtil.signSHA256withRSA(propertyEntity.getPrivateKey(), signString);
     }
 
-    protected Map<String, String> getBaseSignString(SettlementBaseEntity entity) {
+    protected Map<String, String> getBaseSignMap(MerchantPayInRequestEntity entity) {
         Map<String, String> map = new HashMap<>();
         map.put("merchantId", entity.getMerchantId());
         map.put("channelCode", entity.getChannelCode());
         map.put("serial", entity.getSerial());
+        map.put("login", String.valueOf(entity.getLogin()));
         map.put("amount", entity.getAmount().stripTrailingZeros().toPlainString());
         map.put("currency", entity.getCurrency());
         map.put("callbackUrl", entity.getCallbackUrl());
-        map.put("requestTime", DateUtil.formatTime(entity.getRequestTime()));
+        map.put("requestTime", String.valueOf(entity.getRequestTime()));
+        map.put("code", entity.getCode());
+        map.put("name", entity.getName());
+        map.put("email", entity.getEmail());
+        map.put("phone", entity.getPhone());
+        map.put("extParam", entity.getExtParam());
+        map.put("bankCode", entity.getBankCode());
+        return map;
+    }
 
+    protected Map<String, String> getBaseWithdrawSignMap(MerchantPayOutRequestEntity entity) {
+        Map<String, String> map = new HashMap<>();
+        map.put("merchantId", entity.getMerchantId());
+        map.put("channelCode", entity.getChannelCode());
+        map.put("serial", entity.getSerial());
+        map.put("login", String.valueOf(entity.getLogin()));
+        map.put("amount", entity.getAmount().stripTrailingZeros().toPlainString());
+        map.put("currency", entity.getCurrency());
+        map.put("callbackUrl", entity.getCallbackUrl());
+        map.put("requestTime", String.valueOf(entity.getRequestTime()));
+        map.put("code", entity.getCode());
+        map.put("name", entity.getName());
+        map.put("email", entity.getEmail());
+        map.put("phone", entity.getPhone());
+        map.put("extParam", entity.getExtParam());
+        map.put("bankCode", entity.getBankCode());
+        map.put("address", entity.getAddress());
+        map.put("bankUname", entity.getBankUname());
+        map.put("bankCardNum", entity.getBankCardNum());
+        map.put("bankName", entity.getBankName());
+        map.put("bankBranchName", entity.getBankBranchName());
+        map.put("bankAddr", entity.getBankAddr());
+        map.put("swiftCode", entity.getSwiftCode());
         return map;
     }
 

+ 68 - 0
crm-settlement/src/main/resources/mapper/SettlementDepositRecordMapper.xml

@@ -3,6 +3,74 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.crm.settlement.dao.mapper.SettlementDepositRecordMapper">
+    <select id="countList" resultType="integer"
+            parameterType="com.crm.rely.backend.model.entity.settlement.SettlementDepositListSearchEntity">
+
+        select count(*) from settlement_deposit_record
+        <where>
+            <if test="serial != null and serial != ''">
+                and `serial` = #{serial}
+            </if>
+            <if test="login != null and login != ''">
+                and `login` = #{login}
+            </if>
+            <if test="name != null and name != ''">
+                and `name` = #{name}
+            </if>
+            <if test="email != null and email != ''">
+                and `email` = #{email}
+            </if>
+            <if test="channelCode != null and channelCode != ''">
+                and `channel_code` = #{channelCode}
+            </if>
+            <if test="callbackMerchantStatus != null">
+                and `callback_merchant_status` = #{callbackMerchantStatus}
+            </if>
+            <if test="startDate != null">
+                and add_time <![CDATA[>=]]>#{startDate}
+            </if>
+            <if test="endDate != null">
+                and add_time <![CDATA[<=]]>#{endDate}
+            </if>
+        </where>
+
+    </select>
+
+    <select id="pageList" resultType="com.crm.rely.backend.model.pojo.table.SettlementDepositRecordTable"
+            parameterType="com.crm.rely.backend.model.entity.settlement.SettlementDepositListSearchEntity">
+
+        select * from settlement_deposit_record
+        <where>
+            <if test="serial != null and serial != ''">
+                and `serial` = #{serial}
+            </if>
+            <if test="login != null and login != ''">
+                and `login` = #{login}
+            </if>
+            <if test="name != null and name != ''">
+                and `name` = #{name}
+            </if>
+            <if test="email != null and email != ''">
+                and `email` = #{email}
+            </if>
+            <if test="channelCode != null and channelCode != ''">
+                and `channel_code` = #{channelCode}
+            </if>
+            <if test="callbackMerchantStatus != null">
+                and `callback_merchant_status` = #{callbackMerchantStatus}
+            </if>
+            <if test="startDate != null">
+                and add_time <![CDATA[>=]]>#{startDate}
+            </if>
+            <if test="endDate != null">
+                and add_time <![CDATA[<=]]>#{endDate}
+            </if>
+        </where>
+        order by add_time desc
+        <if test="page != null">
+            limit #{page.offset},#{page.row}
+        </if>
+    </select>
 
     <select id="getAllCallback" resultType="com.crm.rely.backend.model.pojo.table.SettlementDepositRecordTable">
         SELECT *

+ 68 - 0
crm-settlement/src/main/resources/mapper/SettlementWithdrawRecordMapper.xml

@@ -3,6 +3,74 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.crm.settlement.dao.mapper.SettlementWithdrawRecordMapper">
+    <select id="countList" resultType="integer"
+            parameterType="com.crm.rely.backend.model.entity.settlement.SettlementWithdrawListSearchEntity">
+
+        select count(*) from settlement_withdraw_record
+        <where>
+            <if test="serial != null and serial != ''">
+                and `serial` = #{serial}
+            </if>
+            <if test="login != null and login != ''">
+                and `login` = #{login}
+            </if>
+            <if test="name != null and name != ''">
+                and `name` = #{name}
+            </if>
+            <if test="email != null and email != ''">
+                and `email` = #{email}
+            </if>
+            <if test="channelCode != null and channelCode != ''">
+                and `channel_code` = #{channelCode}
+            </if>
+            <if test="callbackMerchantStatus != null">
+                and `callback_merchant_status` = #{callbackMerchantStatus}
+            </if>
+            <if test="startDate != null">
+                and add_time <![CDATA[>=]]>#{startDate}
+            </if>
+            <if test="endDate != null">
+                and add_time <![CDATA[<=]]>#{endDate}
+            </if>
+        </where>
+
+    </select>
+
+    <select id="pageList" resultType="com.crm.rely.backend.model.pojo.table.SettlementWithdrawRecordTable"
+            parameterType="com.crm.rely.backend.model.entity.settlement.SettlementWithdrawListSearchEntity">
+
+        select * from settlement_withdraw_record
+        <where>
+            <if test="serial != null and serial != ''">
+                and `serial` = #{serial}
+            </if>
+            <if test="login != null and login != ''">
+                and `login` = #{login}
+            </if>
+            <if test="name != null and name != ''">
+                and `name` = #{name}
+            </if>
+            <if test="email != null and email != ''">
+                and `email` = #{email}
+            </if>
+            <if test="channelCode != null and channelCode != ''">
+                and `channel_code` = #{channelCode}
+            </if>
+            <if test="callbackMerchantStatus != null">
+                and `callback_merchant_status` = #{callbackMerchantStatus}
+            </if>
+            <if test="startDate != null">
+                and add_time <![CDATA[>=]]>#{startDate}
+            </if>
+            <if test="endDate != null">
+                and add_time <![CDATA[<=]]>#{endDate}
+            </if>
+        </where>
+        order by add_time desc
+        <if test="page != null">
+            limit #{page.offset},#{page.row}
+        </if>
+    </select>
 
     <select id="getAllCallback" resultType="com.crm.rely.backend.model.pojo.table.SettlementWithdrawRecordTable">
         SELECT *