|
|
@@ -46,6 +46,8 @@ import lombok.SneakyThrows;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.core.io.ClassPathResource;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@@ -275,7 +277,8 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
@SneakyThrows
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void wxNotify(HttpServletRequest request) {
|
|
|
+ public ResponseEntity<Object> wxNotify(HttpServletRequest request) {
|
|
|
+
|
|
|
var notifyRes = handleWxNotify(request);
|
|
|
|
|
|
try {
|
|
|
@@ -284,7 +287,7 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
LOGGER.info("微信支付回调{}:验签解密完毕,数据:\n{}", notifyRes[2], transaction);
|
|
|
// 判断是否已经接收处理过通知
|
|
|
if (payLogService.lambdaQuery().eq(PayLog::getOutTradeNo, transaction.getOutTradeNo()).one() != null) {
|
|
|
- return;
|
|
|
+ return ResponseEntity.status(HttpStatus.OK).build();
|
|
|
}
|
|
|
|
|
|
DateTime dt = DateUtil.parse(transaction.getSuccessTime());
|
|
|
@@ -329,17 +332,16 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
var res = enPlusService.updateBalanceByQueryEquipChargeStatus(chargingOrder.getStartChargeSeq(), account.getBalance() - 50);
|
|
|
LOGGER.info("用户:{}充电过程中充值,已更新en+充电金额,en+返回数据:{}", account.getUserId(), res);
|
|
|
}
|
|
|
+ return ResponseEntity.status(HttpStatus.OK).build();
|
|
|
|
|
|
} else {
|
|
|
LOGGER.error("微信支付通知处理异常,资金流水为空,回调信息:{}", transaction);
|
|
|
-// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- throw new BusinessException("处理异常");
|
|
|
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(Map.of("code", HttpStatus.INTERNAL_SERVER_ERROR, "message", "资金流水为空"));
|
|
|
}
|
|
|
} catch (ValidationException e) {
|
|
|
// 签名验证失败,返回 401 UNAUTHORIZED 状态码
|
|
|
LOGGER.error("微信支付通知验签失败", e);
|
|
|
- throw new BusinessException("验签失败");
|
|
|
-// return ResponseEntity.status(HttpStatus.UNAUTHORIZED);
|
|
|
+ return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(Map.of("code", HttpStatus.UNAUTHORIZED, "message", "验签失败"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -723,8 +725,8 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
public void fapiaoApplication(String invoiceId) {
|
|
|
var invoice = invoiceService.lambdaQuery().eq(Invoice::getId, invoiceId).one();
|
|
|
|
|
|
- // TODO: 2023-10-14 订单金额+ ,服务费优惠金额- 服务费优惠金额单独一个item,金额为负数
|
|
|
-
|
|
|
+ // TODO: 2023-10-14 订单金额+ ,服务费优惠金额- 服务费优惠金额单独一个item,金额为负数
|
|
|
+
|
|
|
// 电费 税务商品编码:1100101020000000000
|
|
|
var elecMoney = invoice.getOrderDetails().stream().mapToInt(InvoiceOrderDetail::getElecMoney).sum();
|
|
|
var elecMoneyItem = new FaPiao.FaPiaoInfomation.IssueItem().setTotalAmount(elecMoney).setTaxCode("1100101020000000000");
|
|
|
@@ -854,5 +856,4 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|