|
|
@@ -16,6 +16,8 @@ import javax.servlet.http.HttpServletRequest; |
|
|
import java.nio.charset.Charset; |
|
|
import java.nio.charset.Charset; |
|
|
import java.util.LinkedHashMap; |
|
|
import java.util.LinkedHashMap; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.SortedMap; |
|
|
|
|
|
import java.util.TreeMap; |
|
|
|
|
|
|
|
|
@RestController |
|
|
@RestController |
|
|
@RequestMapping("/WxPay/notify") |
|
|
@RequestMapping("/WxPay/notify") |
|
|
@@ -34,35 +36,47 @@ public class WxPayController extends BaseController { |
|
|
* @return 接收微信异步通知 |
|
|
* @return 接收微信异步通知 |
|
|
* @throws Exception 可能产生的任何异常 |
|
|
* @throws Exception 可能产生的任何异常 |
|
|
*/ |
|
|
*/ |
|
|
@RequestMapping(value = "/pay", method = RequestMethod.POST) |
|
|
|
|
|
|
|
|
@RequestMapping(value = "/pay") |
|
|
public String _payNotify(HttpServletRequest request) throws Exception { |
|
|
public String _payNotify(HttpServletRequest request) throws Exception { |
|
|
|
|
|
|
|
|
Map<String, String> paramMap = null; |
|
|
Map<String, String> paramMap = null; |
|
|
String response; |
|
|
|
|
|
try { |
|
|
try { |
|
|
String xml = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8")); |
|
|
String xml = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8")); |
|
|
paramMap = WxPayment.xmlToMap(xml); |
|
|
paramMap = WxPayment.xmlToMap(xml); |
|
|
logger.info("payment wxpay, notify, param: " + paramMap.toString() ); |
|
|
logger.info("payment wxpay, notify, param: " + paramMap.toString() ); |
|
|
response = wxPayOrderService.notify(paramMap, EnumPayWay.PAY_WAY_WEAPP); |
|
|
|
|
|
|
|
|
String response = wxPayOrderService.notify(paramMap, EnumPayWay.PAY_WAY_WEAPP); |
|
|
logger.info("payment wxpay, notify success, req : " + paramMap.toString() + ", resp: " + response.toString()); |
|
|
logger.info("payment wxpay, notify success, req : " + paramMap.toString() + ", resp: " + response.toString()); |
|
|
return response; |
|
|
return response; |
|
|
} catch (BizMessageException e) { |
|
|
} catch (BizMessageException e) { |
|
|
logger.error("payment wxpay, notify error, req: " + paramMap.toString() + ", e:" + e.getLocalizedMessage()); |
|
|
|
|
|
Map<String, String> resultMap = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
|
if (paramMap == null) { |
|
|
|
|
|
logger.error("payment wxpay, order create error, e: " + e.getMessage()); |
|
|
|
|
|
} else { |
|
|
|
|
|
logger.error("payment wxpay, order create error, req: " + paramMap.toString() + ", e: " + e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
SortedMap resultMap = new TreeMap<>(); |
|
|
resultMap.put("return_code", "FAIL"); |
|
|
resultMap.put("return_code", "FAIL"); |
|
|
resultMap.put("return_msg", e.getMessage()); |
|
|
resultMap.put("return_msg", e.getMessage()); |
|
|
return XmlUtil.parseDto2Xml(resultMap, ""); |
|
|
|
|
|
|
|
|
return XmlUtil.getRequestXml(resultMap); |
|
|
} catch (MallinkException e) { |
|
|
} catch (MallinkException e) { |
|
|
logger.error("payment wxpay, notify error, req: " + paramMap.toString() + ", e:" +e.getLocalizedMessage()); |
|
|
|
|
|
Map<String, String> resultMap = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
|
if (paramMap == null) { |
|
|
|
|
|
logger.error("payment wxpay, order create error, e: " + e.getMessage()); |
|
|
|
|
|
} else { |
|
|
|
|
|
logger.error("payment wxpay, order create error, req: " + paramMap.toString() + ", e: " + e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
SortedMap resultMap = new TreeMap<>(); |
|
|
resultMap.put("return_code", "FAIL"); |
|
|
resultMap.put("return_code", "FAIL"); |
|
|
resultMap.put("return_msg", e.getMessage()); |
|
|
resultMap.put("return_msg", e.getMessage()); |
|
|
return XmlUtil.parseDto2Xml(resultMap, ""); |
|
|
|
|
|
|
|
|
return XmlUtil.getRequestXml(resultMap); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
logger.error("payment wxpay, order create error, req: " + paramMap.toString() + ", e: " + e.getMessage()); |
|
|
|
|
|
Map<String, String> resultMap = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
|
if (paramMap == null) { |
|
|
|
|
|
logger.error("payment wxpay, order create error, e: " + e.getMessage()); |
|
|
|
|
|
} else { |
|
|
|
|
|
logger.error("payment wxpay, order create error, req: " + paramMap.toString() + ", e: " + e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
SortedMap resultMap = new TreeMap(); |
|
|
resultMap.put("return_code", "FAIL"); |
|
|
resultMap.put("return_code", "FAIL"); |
|
|
resultMap.put("return_msg", e.getMessage()); |
|
|
resultMap.put("return_msg", e.getMessage()); |
|
|
return XmlUtil.parseDto2Xml(resultMap, ""); |
|
|
|
|
|
|
|
|
return XmlUtil.getRequestXml(resultMap); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -72,7 +86,7 @@ public class WxPayController extends BaseController { |
|
|
* @return 接收微信退款异步通知 |
|
|
* @return 接收微信退款异步通知 |
|
|
* @throws Exception 可能产生的任何异常 |
|
|
* @throws Exception 可能产生的任何异常 |
|
|
*/ |
|
|
*/ |
|
|
@RequestMapping(value = "/refund", method = RequestMethod.POST) |
|
|
|
|
|
|
|
|
@RequestMapping(value = "/refund") |
|
|
public String __refundNotify(HttpServletRequest request) throws Exception { |
|
|
public String __refundNotify(HttpServletRequest request) throws Exception { |
|
|
Map<String, String> paramMap = null; |
|
|
Map<String, String> paramMap = null; |
|
|
String response; |
|
|
String response; |
|
|
|