|
@@ -21,6 +21,7 @@ import org.dom4j.DocumentException;
|
|
|
import org.dom4j.DocumentHelper;
|
|
|
import org.dom4j.Element;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
@@ -38,6 +39,7 @@ import java.io.InputStream;
|
|
|
import java.security.KeyStore;
|
|
|
import java.security.SecureRandom;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
@@ -96,8 +98,9 @@ public class WxApiService {
|
|
|
return ResultVoUtil.success(map);
|
|
|
}
|
|
|
|
|
|
+ @Async
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public ResultVo<String> refundOrder(RefundParam param) throws Exception {
|
|
|
+ public CompletableFuture<ResultVo<String>> refundOrder(RefundParam param) throws Exception {
|
|
|
log.info("退款申请:{}", JSON.toJSONStringWithDateFormat(param, "yyyy-MM-dd HH:mm:ss"));
|
|
|
String nonceStr = SnowFlakeId.instance().nextId();
|
|
|
String outRefundNo = SnowFlakeId.instance().nextId();
|
|
@@ -129,20 +132,20 @@ public class WxApiService {
|
|
|
if (root.element("return_code").getStringValue().equals("SUCCESS")) {
|
|
|
Element refundIdEle = root.element("refund_id");
|
|
|
if (null == refundIdEle) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, root.element("err_code_des").getStringValue());
|
|
|
+ return CompletableFuture.completedFuture(ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, root.element("err_code_des").getStringValue()));
|
|
|
}
|
|
|
param.setRefundId(refundIdEle.getStringValue());
|
|
|
dao.updateRefundId(param);
|
|
|
log.info("微信退款成功:{}", param);
|
|
|
- return ResultVoUtil.success(param.getRefundId());
|
|
|
+ return CompletableFuture.completedFuture(ResultVoUtil.success(param.getRefundId()));
|
|
|
} else {
|
|
|
final String message = root.element("return_msg").getStringValue();
|
|
|
log.info("微信退款失败:{}", message);
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, message);
|
|
|
+ return CompletableFuture.completedFuture(ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, message));
|
|
|
}
|
|
|
} catch (DocumentException e) {
|
|
|
e.printStackTrace();
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, e.getMessage());
|
|
|
+ return CompletableFuture.completedFuture(ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, e.getMessage()));
|
|
|
}
|
|
|
}
|
|
|
|