|
@@ -25,6 +25,7 @@ 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.BizException;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.constants.Capacity;
|
|
|
import thyyxxk.webserver.dao.his.outpatient.WxApiDao;
|
|
@@ -79,21 +80,21 @@ public class WxApiService {
|
|
|
return ResultVoUtil.success(map);
|
|
|
}
|
|
|
|
|
|
- @Async
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public CompletableFuture<ResultVo<String>> refundOrder(RefundParam param) throws Exception {
|
|
|
+ public 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();
|
|
|
- String cashpayAmt = DecimalUtil.moneyYuanToFen(param.getCashpayAmt());
|
|
|
+ String refundAmt = DecimalUtil.moneyYuanToFen(param.getRefundAmt());
|
|
|
+ String totalFee = DecimalUtil.moneyYuanToFen(param.getTotalFee());
|
|
|
TreeMap<String, String> map = new TreeMap<>();
|
|
|
map.put("appid", WxCertUtil.APP_ID);
|
|
|
map.put("mch_id", WxCertUtil.MERCHANT_ID);
|
|
|
map.put("nonce_str", nonceStr);
|
|
|
map.put("out_refund_no", outRefundNo);
|
|
|
map.put("out_trade_no", param.getTradeNo());
|
|
|
- map.put("refund_fee", cashpayAmt);
|
|
|
- map.put("total_fee", cashpayAmt);
|
|
|
+ map.put("refund_fee", refundAmt);
|
|
|
+ map.put("total_fee", totalFee);
|
|
|
String refundSign = Md5Util.createWxPaySign(map);
|
|
|
String xml = "<xml>" +
|
|
|
"<appid>" + WxCertUtil.APP_ID + "</appid>" +
|
|
@@ -101,8 +102,8 @@ public class WxApiService {
|
|
|
"<nonce_str>" + nonceStr + "</nonce_str>" +
|
|
|
"<out_refund_no>" + outRefundNo + "</out_refund_no>" +
|
|
|
"<out_trade_no>" + param.getTradeNo() + "</out_trade_no>" +
|
|
|
- "<refund_fee>" + cashpayAmt + "</refund_fee>" +
|
|
|
- "<total_fee>" + cashpayAmt + "</total_fee>" +
|
|
|
+ "<refund_fee>" + refundAmt + "</refund_fee>" +
|
|
|
+ "<total_fee>" + totalFee + "</total_fee>" +
|
|
|
"<sign>" + refundSign + "</sign>" +
|
|
|
"</xml>";
|
|
|
String str = requestWithSsl(xml);
|
|
@@ -116,16 +117,16 @@ public class WxApiService {
|
|
|
if ("订单已全额退款".equals(msg)) {
|
|
|
dao.alreadyRefund(param.getTradeNo(), msg);
|
|
|
}
|
|
|
- return CompletableFuture.completedFuture(ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, msg));
|
|
|
+ throw new BizException(msg);
|
|
|
}
|
|
|
param.setRefundId(refundIdEle.getStringValue());
|
|
|
dao.updateRefundId(param);
|
|
|
log.info("微信退款成功:{}", param);
|
|
|
- return CompletableFuture.completedFuture(ResultVoUtil.success(param.getRefundId()));
|
|
|
+ return param.getRefundId();
|
|
|
}
|
|
|
final String message = root.element("return_msg").getStringValue();
|
|
|
log.info("微信退款失败:{}", message);
|
|
|
- return CompletableFuture.completedFuture(ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, message));
|
|
|
+ throw new BizException(message);
|
|
|
}
|
|
|
|
|
|
private String requestWithSsl(String xml) throws Exception {
|