|
|
|
@@ -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<String, String> 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); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |