diff --git a/jsowell-common/src/main/java/com/jsowell/common/config/AutoSettleConfig.java b/jsowell-common/src/main/java/com/jsowell/common/config/AutoSettleConfig.java new file mode 100644 index 000000000..d6db4614d --- /dev/null +++ b/jsowell-common/src/main/java/com/jsowell/common/config/AutoSettleConfig.java @@ -0,0 +1,163 @@ +package com.jsowell.common.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +/** + * 无交易记录自动结算配置 + * + * @author jsowell + */ +@Component +@ConfigurationProperties(prefix = "auto-settle") +public class AutoSettleConfig { + + /** + * 总开关,默认关闭 + */ + private boolean enabled = false; + + /** + * 停止充电超时阈值(分钟),超过此时间未收到交易记录则触发自动结算 + */ + private int timeoutMinutes = 10; + + /** + * 定时任务扫描周期(Cron表达式),每10分钟扫描一次 + */ + private String interval = "0 */10 * * * ?"; + + /** + * 灰度站点白名单(站点ID列表),仅对这些站点启用自动结算 + */ + private List grayscaleStationIds = new ArrayList<>(); + + /** + * 金额异常阈值倍数,chargingAmount > payAmount * 此值时告警跳过 + */ + private double amountThresholdRatio = 1.5; + + /** + * 单次扫描订单数量上限,防止一次查询过多订单 + */ + private int batchSize = 100; + + /** + * 实时数据新鲜度阈值(分钟),数据超过此时间未更新视为桩假在线 + */ + private int dataFreshnessMinutes = 30; + + /** + * 告警开关 + */ + private boolean alertEnabled = true; + + /** + * Redis分布式锁超时时间(秒) + */ + private int lockTimeoutSeconds = 60; + + /** + * 失败是否重试,建议false等待下一轮扫描 + */ + private boolean retryOnFailure = false; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public int getTimeoutMinutes() { + return timeoutMinutes; + } + + public void setTimeoutMinutes(int timeoutMinutes) { + this.timeoutMinutes = timeoutMinutes; + } + + public String getInterval() { + return interval; + } + + public void setInterval(String interval) { + this.interval = interval; + } + + public List getGrayscaleStationIds() { + return grayscaleStationIds; + } + + public void setGrayscaleStationIds(List grayscaleStationIds) { + this.grayscaleStationIds = grayscaleStationIds; + } + + public double getAmountThresholdRatio() { + return amountThresholdRatio; + } + + public void setAmountThresholdRatio(double amountThresholdRatio) { + this.amountThresholdRatio = amountThresholdRatio; + } + + public int getBatchSize() { + return batchSize; + } + + public void setBatchSize(int batchSize) { + this.batchSize = batchSize; + } + + public int getDataFreshnessMinutes() { + return dataFreshnessMinutes; + } + + public void setDataFreshnessMinutes(int dataFreshnessMinutes) { + this.dataFreshnessMinutes = dataFreshnessMinutes; + } + + public boolean isAlertEnabled() { + return alertEnabled; + } + + public void setAlertEnabled(boolean alertEnabled) { + this.alertEnabled = alertEnabled; + } + + public int getLockTimeoutSeconds() { + return lockTimeoutSeconds; + } + + public void setLockTimeoutSeconds(int lockTimeoutSeconds) { + this.lockTimeoutSeconds = lockTimeoutSeconds; + } + + public boolean isRetryOnFailure() { + return retryOnFailure; + } + + public void setRetryOnFailure(boolean retryOnFailure) { + this.retryOnFailure = retryOnFailure; + } + + @Override + public String toString() { + return "AutoSettleConfig{" + + "enabled=" + enabled + + ", timeoutMinutes=" + timeoutMinutes + + ", interval='" + interval + '\'' + + ", grayscaleStationIds=" + grayscaleStationIds + + ", amountThresholdRatio=" + amountThresholdRatio + + ", batchSize=" + batchSize + + ", dataFreshnessMinutes=" + dataFreshnessMinutes + + ", alertEnabled=" + alertEnabled + + ", lockTimeoutSeconds=" + lockTimeoutSeconds + + ", retryOnFailure=" + retryOnFailure + + '}'; + } +}