Commit 5562d9905519886d29fe0bbb3b7f0249779b1561
1 parent
01f6a2ee
cashier optimization
Showing
4 changed files
with
28 additions
and
7 deletions
cashier-pipeline/src/main/java/com/diligrp/cashier/pipeline/core/DefaultTimeStrategy.java
| 1 | package com.diligrp.cashier.pipeline.core; | 1 | package com.diligrp.cashier.pipeline.core; |
| 2 | 2 | ||
| 3 | -import static com.diligrp.cashier.pipeline.Constants.*; | ||
| 4 | - | ||
| 5 | public class DefaultTimeStrategy implements ScanTimeStrategy { | 3 | public class DefaultTimeStrategy implements ScanTimeStrategy { |
| 4 | + | ||
| 6 | // 预支付订单扫描时间策略 | 5 | // 预支付订单扫描时间策略 |
| 7 | - private final long[] prepayTimeArray = { 10 * ONE_MINUTE }; | 6 | + private final long[] prepayTimeArray; |
| 8 | 7 | ||
| 9 | // 直接支付订单扫描时间策略 | 8 | // 直接支付订单扫描时间策略 |
| 10 | - private final long[] paymentTimeArray = { 5 * ONE_SECOND, 5 * ONE_SECOND, 5 * ONE_SECOND, 5 * ONE_SECOND, 5 * ONE_SECOND, 5 * ONE_SECOND, 5 * ONE_SECOND, 5 * ONE_SECOND, 10 * ONE_SECOND, 15 * ONE_SECOND }; | 9 | + private final long[] paymentTimeArray; |
| 11 | 10 | ||
| 12 | // 退款订单扫描时间策略 | 11 | // 退款订单扫描时间策略 |
| 13 | - private final long[] refundTimeArray = { ONE_MINUTE, 2 * ONE_MINUTE, 2 * ONE_MINUTE, 5 * ONE_MINUTE }; | 12 | + private final long[] refundTimeArray; |
| 13 | + | ||
| 14 | + public DefaultTimeStrategy() { | ||
| 15 | + this.prepayTimeArray = DEFAULT_PREPAY_TIME_ARRAY; | ||
| 16 | + this.paymentTimeArray = DEFAULT_PAYMENT_TIME_ARRAY; | ||
| 17 | + this.refundTimeArray = DEFAULT_REFUND_TIME_ARRAY; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + public DefaultTimeStrategy(long[] prepayTimeArray, long[] paymentTimeArray, long[] refundTimeArray) { | ||
| 21 | + this.prepayTimeArray = prepayTimeArray; | ||
| 22 | + this.paymentTimeArray = paymentTimeArray; | ||
| 23 | + this.refundTimeArray = refundTimeArray; | ||
| 24 | + } | ||
| 14 | 25 | ||
| 15 | @Override | 26 | @Override |
| 16 | public long nextPrepayScanTime(int times) { | 27 | public long nextPrepayScanTime(int times) { |
cashier-pipeline/src/main/java/com/diligrp/cashier/pipeline/core/RcbOnlinePipeline.java
| @@ -37,7 +37,8 @@ public class RcbOnlinePipeline extends OnlinePipeline<RcbOnlinePipeline.RcbParam | @@ -37,7 +37,8 @@ public class RcbOnlinePipeline extends OnlinePipeline<RcbOnlinePipeline.RcbParam | ||
| 37 | checkParam(config.getKey(), "key"); | 37 | checkParam(config.getKey(), "key"); |
| 38 | checkParam(config.getNotifyUrl(), "notifyUrl"); | 38 | checkParam(config.getNotifyUrl(), "notifyUrl"); |
| 39 | this.client = new RcbOnlineHttpClient(uri, config.getMerchantNo(), config.getTerminalNo(), config.getKey(), config.getAppId()); | 39 | this.client = new RcbOnlineHttpClient(uri, config.getMerchantNo(), config.getTerminalNo(), config.getKey(), config.getAppId()); |
| 40 | - this.strategy = new DefaultTimeStrategy(); | 40 | + // 农商行没有退款查询接口不需要退款查询时间策略 |
| 41 | + this.strategy = new DefaultTimeStrategy(ScanTimeStrategy.DEFAULT_PREPAY_TIME_ARRAY, ScanTimeStrategy.DEFAULT_PAYMENT_TIME_ARRAY, new long[0]); | ||
| 41 | } | 42 | } |
| 42 | 43 | ||
| 43 | /** | 44 | /** |
cashier-pipeline/src/main/java/com/diligrp/cashier/pipeline/core/ScanTimeStrategy.java
| 1 | package com.diligrp.cashier.pipeline.core; | 1 | package com.diligrp.cashier.pipeline.core; |
| 2 | 2 | ||
| 3 | +import static com.diligrp.cashier.pipeline.Constants.ONE_MINUTE; | ||
| 4 | +import static com.diligrp.cashier.pipeline.Constants.ONE_SECOND; | ||
| 5 | + | ||
| 3 | public interface ScanTimeStrategy { | 6 | public interface ScanTimeStrategy { |
| 7 | + long[] DEFAULT_PREPAY_TIME_ARRAY = { 10 * ONE_MINUTE }; | ||
| 8 | + | ||
| 9 | + long[] DEFAULT_PAYMENT_TIME_ARRAY = { 5 * ONE_SECOND, 5 * ONE_SECOND, 5 * ONE_SECOND, | ||
| 10 | + 5 * ONE_SECOND, 5 * ONE_SECOND, 5 * ONE_SECOND, 5 * ONE_SECOND, 5 * ONE_SECOND, 10 * ONE_SECOND, 15 * ONE_SECOND }; | ||
| 11 | + | ||
| 12 | + long[] DEFAULT_REFUND_TIME_ARRAY = { ONE_MINUTE, 2 * ONE_MINUTE, 2 * ONE_MINUTE, 5 * ONE_MINUTE }; | ||
| 13 | + | ||
| 4 | // 预支付订单延迟扫描时间 | 14 | // 预支付订单延迟扫描时间 |
| 5 | long nextPrepayScanTime(int times); | 15 | long nextPrepayScanTime(int times); |
| 6 | 16 |
cashier-shared/src/main/java/com/diligrp/cashier/shared/service/ThreadPoolService.java
| @@ -29,7 +29,6 @@ public final class ThreadPoolService { | @@ -29,7 +29,6 @@ public final class ThreadPoolService { | ||
| 29 | */ | 29 | */ |
| 30 | public static ExecutorService getCpuThreadPoll() { | 30 | public static ExecutorService getCpuThreadPoll() { |
| 31 | if (cpuThreadPoll == null) { | 31 | if (cpuThreadPoll == null) { |
| 32 | - | ||
| 33 | synchronized (ThreadPoolService.class) { | 32 | synchronized (ThreadPoolService.class) { |
| 34 | if (cpuThreadPoll == null) { | 33 | if (cpuThreadPoll == null) { |
| 35 | cpuThreadPoll = new ThreadPoolExecutor(CPU_CORE_NUM + 1, CPU_MAX_POOL_SIZE, 20, | 34 | cpuThreadPoll = new ThreadPoolExecutor(CPU_CORE_NUM + 1, CPU_MAX_POOL_SIZE, 20, |