|
@@ -31,6 +31,8 @@ import com.yohoufo.order.service.IPaymentService; |
|
@@ -31,6 +31,8 @@ import com.yohoufo.order.service.IPaymentService; |
31
|
import com.yohoufo.order.service.cache.CacheCleaner;
|
31
|
import com.yohoufo.order.service.cache.CacheCleaner;
|
32
|
import com.yohoufo.order.service.cache.CacheKeyBuilder;
|
32
|
import com.yohoufo.order.service.cache.CacheKeyBuilder;
|
33
|
import com.yohoufo.order.service.proxy.InBoxFacade;
|
33
|
import com.yohoufo.order.service.proxy.InBoxFacade;
|
|
|
34
|
+import com.yohoufo.order.service.proxy.InBoxThreadFactory;
|
|
|
35
|
+import com.yohoufo.order.utils.PubThreadFactory;
|
34
|
import com.yohoufo.order.utils.SmsHelper;
|
36
|
import com.yohoufo.order.utils.SmsHelper;
|
35
|
import org.slf4j.Logger;
|
37
|
import org.slf4j.Logger;
|
36
|
import org.slf4j.LoggerFactory;
|
38
|
import org.slf4j.LoggerFactory;
|
|
@@ -40,6 +42,10 @@ import org.springframework.stereotype.Service; |
|
@@ -40,6 +42,10 @@ import org.springframework.stereotype.Service; |
40
|
import java.math.BigDecimal;
|
42
|
import java.math.BigDecimal;
|
41
|
import java.util.Arrays;
|
43
|
import java.util.Arrays;
|
42
|
import java.util.List;
|
44
|
import java.util.List;
|
|
|
45
|
+import java.util.concurrent.ArrayBlockingQueue;
|
|
|
46
|
+import java.util.concurrent.ExecutorService;
|
|
|
47
|
+import java.util.concurrent.ThreadPoolExecutor;
|
|
|
48
|
+import java.util.concurrent.TimeUnit;
|
43
|
|
49
|
|
44
|
/**
|
50
|
/**
|
45
|
* Created by chenchao on 2018/9/27.
|
51
|
* Created by chenchao on 2018/9/27.
|
|
@@ -49,6 +55,8 @@ public class AppraiseService { |
|
@@ -49,6 +55,8 @@ public class AppraiseService { |
49
|
|
55
|
|
50
|
private static final Logger LOGGER = LoggerFactory.getLogger(AppraiseService.class);
|
56
|
private static final Logger LOGGER = LoggerFactory.getLogger(AppraiseService.class);
|
51
|
|
57
|
|
|
|
58
|
+ private ExecutorService executorService = new ThreadPoolExecutor(5, 10, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(10), new PubThreadFactory("appraise-processor"));
|
|
|
59
|
+
|
52
|
@Autowired
|
60
|
@Autowired
|
53
|
private IExpressInfoService expressInfoService;
|
61
|
private IExpressInfoService expressInfoService;
|
54
|
|
62
|
|
|
@@ -132,11 +140,18 @@ public class AppraiseService { |
|
@@ -132,11 +140,18 @@ public class AppraiseService { |
132
|
//先校验,提前把错误抛出
|
140
|
//先校验,提前把错误抛出
|
133
|
paymentService.transferMonCheck(tmReq);
|
141
|
paymentService.transferMonCheck(tmReq);
|
134
|
//再分账
|
142
|
//再分账
|
|
|
143
|
+ /**
|
135
|
boolean transferSuccessFlag=transferService.transfer(tmReq);
|
144
|
boolean transferSuccessFlag=transferService.transfer(tmReq);
|
136
|
if(!transferSuccessFlag){
|
145
|
if(!transferSuccessFlag){
|
137
|
apiResponse.setCode(400);
|
146
|
apiResponse.setCode(400);
|
138
|
apiResponse.setMessage("保证金分账失败");
|
147
|
apiResponse.setMessage("保证金分账失败");
|
139
|
}
|
148
|
}
|
|
|
149
|
+ */
|
|
|
150
|
+ //改成异步的分账,不关心分账执行结果
|
|
|
151
|
+ executorService.execute(()->{
|
|
|
152
|
+ LOGGER.info("in appraiseSuccess,begin transfer async");
|
|
|
153
|
+ transferService.transfer(tmReq);
|
|
|
154
|
+ });
|
140
|
|
155
|
|
141
|
/**
|
156
|
/**
|
142
|
* 退保证金给卖家
|
157
|
* 退保证金给卖家
|
|
@@ -267,11 +282,18 @@ public class AppraiseService { |
|
@@ -267,11 +282,18 @@ public class AppraiseService { |
267
|
//先校验,提前把错误抛出
|
282
|
//先校验,提前把错误抛出
|
268
|
paymentService.transferMonCheck(tmReq);
|
283
|
paymentService.transferMonCheck(tmReq);
|
269
|
//再分账
|
284
|
//再分账
|
|
|
285
|
+ /*
|
270
|
boolean transferSuccessFlag=transferService.transfer(tmReq);
|
286
|
boolean transferSuccessFlag=transferService.transfer(tmReq);
|
271
|
if(!transferSuccessFlag){
|
287
|
if(!transferSuccessFlag){
|
272
|
apiResponse.setCode(400);
|
288
|
apiResponse.setCode(400);
|
273
|
apiResponse.setMessage("保证金分账失败");
|
289
|
apiResponse.setMessage("保证金分账失败");
|
274
|
}
|
290
|
}
|
|
|
291
|
+ */
|
|
|
292
|
+ //改成异步的分账,不关心分账执行结果
|
|
|
293
|
+ executorService.execute(()->{
|
|
|
294
|
+ LOGGER.info("in appraiseFail,begin transfer async");
|
|
|
295
|
+ transferService.transfer(tmReq);
|
|
|
296
|
+ });
|
275
|
|
297
|
|
276
|
BigDecimal goodsMoney = buyerOrder.getAmount();
|
298
|
BigDecimal goodsMoney = buyerOrder.getAmount();
|
277
|
PaymentRequest req = PaymentRequest.builder().uid(buyerUid)
|
299
|
PaymentRequest req = PaymentRequest.builder().uid(buyerUid)
|