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.
		
		
		
		
			
				
					
					
						
							65 lines
						
					
					
						
							2.0 KiB
						
					
					
				
			
		
		
	
	
							65 lines
						
					
					
						
							2.0 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;
 | |
| import java.util.UUID;
 | |
| 
 | |
| // 医保回调
 | |
| @Slf4j
 | |
| public class MdRespHelper {
 | |
|     /**
 | |
|      * 失败响应
 | |
|      */
 | |
|     public static String resp(ServiceException e, String mdPayKey) {
 | |
|         if (ResultEnum.PAY_NOTIFY_REPEAT.equals(e.getResultEnum())) { // 重复通知
 | |
|             return respOk(mdPayKey);
 | |
|         }
 | |
|         return respFail(e.getMessage(), mdPayKey);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * 成功响应
 | |
|      */
 | |
|     public static String respOk(String mdPayKey) {
 | |
|         log.info("【医保】回调通知成功");
 | |
|         try {
 | |
|             Map<String, Object> map = new HashMap<>();
 | |
|             map.put("return_code", "SUCCESS");
 | |
|             map.put("result_code", "SUCCESS");
 | |
|             map.put("return_msg", "OK");
 | |
|             map.put("nonce_str", UUID.randomUUID().toString().replace("-", ""));
 | |
|             map.put("sign", WxSignHelper.generateSign(map, WxSignHelper.SIGN_TYPE_MD5, mdPayKey));
 | |
|             return XmlHelper.mapToXml(map);
 | |
|         } catch (Exception e) {
 | |
|             e.printStackTrace();
 | |
|         }
 | |
|         return null;
 | |
|     }
 | |
| 
 | |
| 
 | |
|     /**
 | |
|      * 成功响应
 | |
|      */
 | |
|     public static String respFail(String message, String mdPayKey) {
 | |
|         log.info("【医保】回调通知:{}", message);
 | |
|         if (message == null) {
 | |
|             message = "FAIL";
 | |
|         }
 | |
|         try {
 | |
|             Map<String, Object> map = new HashMap<>();
 | |
|             map.put("return_code", "FAIL");
 | |
|             map.put("result_code", "FAIL");
 | |
|             map.put("return_msg", message);
 | |
|             map.put("nonce_str", UUID.randomUUID().toString().replace("-", ""));
 | |
|             map.put("sign", WxSignHelper.generateSign(map, WxSignHelper.SIGN_TYPE_MD5, mdPayKey));
 | |
|             return XmlHelper.mapToXml(map);
 | |
|         } catch (Exception e) {
 | |
|             e.printStackTrace();
 | |
|         }
 | |
|         return null;
 | |
|     }
 | |
| }
 | |
| 
 |