| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.api.web; |
| | | |
| | | import com.doumee.config.wx.WxMiniConfig; |
| | | import com.doumee.core.constants.Constants; |
| | | import com.doumee.core.utils.ID; |
| | | import com.doumee.service.business.OrdersService; |
| | | import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse; |
| | | import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.CrossOrigin; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * æ¯ä»åè° |
| | | * |
| | | * @Author : Rk |
| | | * @create 2023/3/24 16:57 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @CrossOrigin |
| | | public class PaymentCallback extends ApiController { |
| | | |
| | | @Autowired |
| | | private OrdersService ordersService; |
| | | |
| | | |
| | | @PostMapping("/web/api/wxPayNotify") |
| | | public String wxPay_notify(@RequestBody String xmlResult) { |
| | | String wxId = ID.nextGUID(); |
| | | log.info("æ¯ä»åè°ä¿¡æ¯("+wxId+") = > " + xmlResult); |
| | | if (StringUtils.isEmpty(xmlResult)){ |
| | | return null; |
| | | } |
| | | try { |
| | | WxPayOrderNotifyResult result = WxMiniConfig.wxPayService.parseOrderNotifyResult(xmlResult); |
| | | //èªå®ä¹è®¢åå· |
| | | String outTradeNo = result.getOutTradeNo(); |
| | | //微信订åå· |
| | | String paymentNo = result.getTransactionId(); |
| | | |
| | | |
| | | |
| | | if (Constants.SUCCESS.equals(result.getReturnCode())) { |
| | | // æ¯ä»æå |
| | | switch (result.getAttach()) { |
| | | //å¯å订å |
| | | case "storageOrder": { |
| | | ordersService.handleStorageOrderPayNotify(outTradeNo, paymentNo); |
| | | break; |
| | | } |
| | | //åºéºæ¼é订å |
| | | case "shopDeposit": { |
| | | |
| | | break; |
| | | } |
| | | //é¾æè´¹ç¨è®¢å |
| | | case "overdueFee": { |
| | | |
| | | break; |
| | | } |
| | | } |
| | | return WxPayNotifyResponse.success("å¤çæå!"); |
| | | } |
| | | return WxPayNotifyResponse.fail(result.getReturnMsg()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("微信åè°ç»æå¼å¸¸,å¼å¸¸åå {}", e.getLocalizedMessage()); |
| | | return WxPayNotifyResponse.fail(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |