You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					
					
						
							64 lines
						
					
					
						
							1.7 KiB
						
					
					
				
			
		
		
	
	
							64 lines
						
					
					
						
							1.7 KiB
						
					
					
				package com.ynxbd.wx.wxfactory.utils;
 | 
						|
 | 
						|
import com.ynxbd.common.result.ResultEnum;
 | 
						|
import com.ynxbd.common.result.ServiceException;
 | 
						|
import lombok.extern.slf4j.Slf4j;
 | 
						|
 | 
						|
import java.util.HashMap;
 | 
						|
import java.util.Map;
 | 
						|
 | 
						|
@Slf4j
 | 
						|
public class WxRespHelper {
 | 
						|
 | 
						|
    /**
 | 
						|
     * 成功相应
 | 
						|
     */
 | 
						|
    public static String resp(ServiceException e) {
 | 
						|
        if (ResultEnum.PAY_NOTIFY_REPEAT.equals(e.getResultEnum())) {
 | 
						|
            return respOk();
 | 
						|
        }
 | 
						|
        return respFail(e.getMessage());
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * 成功响应
 | 
						|
     */
 | 
						|
    public static String respOk() {
 | 
						|
        log.info("【微信】回调通知成功");
 | 
						|
        try {
 | 
						|
            Map<String, Object> map = new HashMap<>();
 | 
						|
            map.put("return_code", "SUCCESS");
 | 
						|
            map.put("return_msg", "OK");
 | 
						|
            return XmlHelper.mapToXml(map);
 | 
						|
        } catch (Exception e) {
 | 
						|
            e.printStackTrace();
 | 
						|
        }
 | 
						|
        return null;
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    /**
 | 
						|
     * 失败响应
 | 
						|
     */
 | 
						|
    private static String respFail(String message) {
 | 
						|
        log.info("回调通知: {}", message);
 | 
						|
        if (message == null) {
 | 
						|
            message = "FAIL";
 | 
						|
        }
 | 
						|
        try {
 | 
						|
            Map<String, Object> map = new HashMap<>();
 | 
						|
            map.put("return_code", "FAIL");
 | 
						|
            map.put("return_msg", message);
 | 
						|
            return XmlHelper.mapToXml(map);
 | 
						|
        } catch (Exception e) {
 | 
						|
            e.printStackTrace();
 | 
						|
        }
 | 
						|
        return null;
 | 
						|
    }
 | 
						|
 | 
						|
//    public static void main(String[] args) throws DocumentException {
 | 
						|
//
 | 
						|
//        TestPay testPay = XmlHelper.xmlToBean(xml, TestPay.class);
 | 
						|
//        System.out.println(testPay);
 | 
						|
//    }
 | 
						|
}
 | 
						|
 |