package com.neusoft.smart.pos.payment.controller;

import com.neusoft.smart.pos.payment.service.WXPayNotifyService;
import com.neusoft.smart.pos.payment.service.WXUsPayNotifyService;
import com.neusoft.smart.pos.payment.utils.HttpClientUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping(path = "/wxUsPayNotify")
public class WXUsPayNotifyController {

	@Autowired
	private WXUsPayNotifyService wxPayNotifyService;

	/**
	 * 微信支付成功回调方法
	 * @return
	 */
	@ApiIgnore
	@RequestMapping(value = "payNotify")
	public String weixinPayNotify(HttpServletRequest request){
		String notifyXmlData = HttpClientUtils.getStringDataFromRequest(request);
		return wxPayNotifyService.weixinNotifyDataHandle(notifyXmlData);
	}

	/**
	 * 微信支付退款成功回调方法
	 * @return
	 */
	@ApiIgnore
	@RequestMapping(value = "refundNotify")
	public String weixinRefundNotify(HttpServletRequest request){
		String notifyXmlData = HttpClientUtils.getStringDataFromRequest(request);
		return wxPayNotifyService.weixinRefundNotifyDataHandle(notifyXmlData);
	}

}
	