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

import com.google.common.collect.Maps;
import com.neusoft.smart.pos.payment.service.WXPayNotifyService;
import com.neusoft.smart.pos.payment.utils.HttpClientUtils;
import com.neusoft.smart.pos.payment.utils.WXPayUtils;
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;
import java.util.Map;

@RestController
@RequestMapping(path = "/wxPayNotify")
public class WXPayNotifyController {

	@Autowired
	private WXPayNotifyService 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);
	}

}
	