From 878bb7c9e8156f4c90263293bb426776eac456c1 Mon Sep 17 00:00:00 2001 From: "Stormeye.Wu" Date: Mon, 27 Aug 2018 15:52:09 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=94=AF=E4=BB=98=E5=88=86=E8=B4=A6=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=8E=A5=E5=8F=A3][=E6=96=B0=E5=A2=9E]:=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E5=9B=9E=E8=B0=83=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simple/controller/WxPayController.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxPayController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxPayController.java index af8f9e8d7..b3ed1663a 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxPayController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxPayController.java @@ -5,6 +5,7 @@ import com.simple.exception.BizMessageException; import com.simple.exception.MallinkException; import com.simple.pay.WxPayment; import com.simple.service.WxPayOrderService; +import com.simple.service.WxProfitSharingOrderService; import com.simple.service.WxRefundOrderService; import com.simple.utils.XmlUtil; import org.apache.commons.io.IOUtils; @@ -31,6 +32,9 @@ public class WxPayController extends BaseController { @Autowired private WxRefundOrderService wxRefundOrderService; + @Autowired + private WxProfitSharingOrderService wxProfitSharingOrderService; + /** * * @return 接收微信异步通知 @@ -117,5 +121,42 @@ public class WxPayController extends BaseController { return XmlUtil.getRequestXml(resultMap); } } + + /** + * + * @return 接收微信分账异步通知 + * @throws Exception 可能产生的任何异常 + */ + @RequestMapping(value = "/sharing") + public String __shareNotify(HttpServletRequest request) throws Exception { + Map paramMap = null; + String response; + try { + String xml = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8")); + paramMap = WxPayment.xmlToMap(xml); + logger.info("share wxpay, notify, param: " + paramMap.toString() ); + response = wxPayOrderService.notify(paramMap, EnumPayWay.PAY_WAY_WEAPP); + logger.info("share wxpay, notify success, req : " + paramMap.toString() + ", resp: " + response.toString()); + return response; + } catch (BizMessageException e) { + logger.error("share wxpay, notify error, req: " + paramMap.toString() + ", e:" + e.getLocalizedMessage()); + SortedMap resultMap = new TreeMap(); + resultMap.put("return_code", "FAIL"); + resultMap.put("return_msg", e.getMessage()); + return XmlUtil.getRequestXml(resultMap); + } catch (MallinkException e) { + logger.error("refund wxpay, notify error, req: " + paramMap.toString() + ", e:" +e.getLocalizedMessage()); + SortedMap resultMap = new TreeMap(); + resultMap.put("return_code", "FAIL"); + resultMap.put("return_msg", e.getMessage()); + return XmlUtil.getRequestXml(resultMap); + } catch (Exception e) { + logger.error("refund wxpay, order create error, req: " + paramMap.toString() + ", e: " + e.getMessage()); + SortedMap resultMap = new TreeMap(); + resultMap.put("return_code", "FAIL"); + resultMap.put("return_msg", e.getMessage()); + return XmlUtil.getRequestXml(resultMap); + } + } }