|
@@ -4,13 +4,19 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alipay.api.AlipayApiException;
|
|
import com.alipay.api.AlipayApiException;
|
|
|
import com.alipay.api.internal.util.AlipaySignature;
|
|
import com.alipay.api.internal.util.AlipaySignature;
|
|
|
|
|
+import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
|
|
|
|
|
+import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
|
|
|
|
+import com.github.binarywang.wxpay.exception.WxPayException;
|
|
|
|
|
+import com.github.binarywang.wxpay.service.WxPayService;
|
|
|
import com.izouma.nineth.config.AlipayProperties;
|
|
import com.izouma.nineth.config.AlipayProperties;
|
|
|
|
|
+import com.izouma.nineth.enums.PayMethod;
|
|
|
import com.izouma.nineth.service.OrderService;
|
|
import com.izouma.nineth.service.OrderService;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections.MapUtils;
|
|
import org.apache.commons.collections.MapUtils;
|
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
@@ -29,6 +35,7 @@ public class OrderNotifyController {
|
|
|
|
|
|
|
|
private final AlipayProperties alipayProperties;
|
|
private final AlipayProperties alipayProperties;
|
|
|
private final OrderService orderService;
|
|
private final OrderService orderService;
|
|
|
|
|
+ private final WxPayService wxPayService;
|
|
|
|
|
|
|
|
@PostMapping("/order/alipay")
|
|
@PostMapping("/order/alipay")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
@@ -60,11 +67,28 @@ public class OrderNotifyController {
|
|
|
switch (action) {
|
|
switch (action) {
|
|
|
case "payOrder":
|
|
case "payOrder":
|
|
|
Long orderId = body.getLong("orderId");
|
|
Long orderId = body.getLong("orderId");
|
|
|
- orderService.notifyAlipay(orderId, params);
|
|
|
|
|
|
|
+ orderService.notifyAlipay(orderId, PayMethod.ALIPAY, MapUtils.getString(params, "trade_no"));
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
return "success";
|
|
return "success";
|
|
|
}
|
|
}
|
|
|
return "error";
|
|
return "error";
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping(value = "/payNotify", produces = "application/xml")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public String wxNotify(@RequestBody String xmlData) throws WxPayException {
|
|
|
|
|
+ log.info("微信支付回调: {}", xmlData);
|
|
|
|
|
+ final WxPayOrderNotifyResult notifyResult = wxPayService.parseOrderNotifyResult(xmlData);
|
|
|
|
|
+ notifyResult.checkResult(wxPayService, "MD5", true);
|
|
|
|
|
+ JSONObject attach = JSONObject.parseObject(notifyResult.getAttach());
|
|
|
|
|
+ String action = attach.getString("action");
|
|
|
|
|
+ switch (action) {
|
|
|
|
|
+ case "payOrder":
|
|
|
|
|
+ Long orderId = attach.getLong("orderId");
|
|
|
|
|
+ orderService.notifyAlipay(orderId, PayMethod.WEIXIN, notifyResult.getTransactionId());
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ return WxPayNotifyResponse.success("OK");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|