| | |
| | | import com.google.gson.GsonBuilder; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.order.domain.dto.WechatPaymentRefundDto; |
| | | import com.ruoyi.order.domain.dto.WeixinPaymentNotifyDto; |
| | | import com.ruoyi.order.domain.pojo.account.OrderRefund; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.security.GeneralSecurityException; |
| | | import java.util.Collection; |
| | | import java.util.Enumeration; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * @program: ruoyi |
| | |
| | | @Resource |
| | | private OrderRefundService orderRefundService; |
| | | |
| | | @Resource |
| | | private RedisService redisService; |
| | | |
| | | @PostMapping(value = "/payNotify") |
| | | @ApiOperation(value = "微信支付/退款通知") |
| | | public String payNotify(@RequestBody String notifyData, HttpServletRequest request, HttpServletResponse response) throws WxPayException { |
| | |
| | | PartnerTransactionsResult result = notifyResult.getResult(); |
| | | // 支付通知回调 |
| | | if ("SUCCESS".equals(result.getTradeState())) { |
| | | orderService.payBack(result); |
| | | orderService.payBack(result, BigDecimal.ONE); |
| | | } |
| | | resultMessage = GSON.toJson(notifyResult); |
| | | } else if (WxPayNotifyEventTypeEnum.REFUND_SUCCESS.getCode().equals(eventType) |
| | |
| | | if("S".equals(transStat)){ |
| | | PartnerTransactionsResult transaction = new PartnerTransactionsResult(); |
| | | transaction.setOutTradeNo(data.getReqSeqId()); |
| | | |
| | | //防止回调频繁导致时间处理异常 |
| | | Object cacheObject = redisService.getCacheObject(data.getReqSeqId()); |
| | | if(null == cacheObject){ |
| | | redisService.setCacheObject(data.getReqSeqId(), "", 10L, TimeUnit.SECONDS); |
| | | }else{ |
| | | return; |
| | | } |
| | | //开始处理业务数据 |
| | | orderService.payBack(transaction); |
| | | orderService.payBack(transaction, data.getFeeFlag() == 1 ? BigDecimal.ZERO : new BigDecimal(data.getFeeAmount())); |
| | | |
| | | response.setStatus(200); |
| | | PrintWriter out = null; |