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.
		
		
		
		
			
				
					
					
						
							123 lines
						
					
					
						
							4.8 KiB
						
					
					
				
			
		
		
	
	
							123 lines
						
					
					
						
							4.8 KiB
						
					
					
				| package com.ynxbd.common.action.pay;
 | |
| 
 | |
| import com.ynxbd.common.action.base.BaseAction;
 | |
| import com.ynxbd.common.bean.enums.MerchantEnum;
 | |
| import com.ynxbd.common.result.Result;
 | |
| import com.ynxbd.common.result.ServiceException;
 | |
| import com.ynxbd.common.service.*;
 | |
| import com.ynxbd.wx.wxfactory.WxPayHelper;
 | |
| import com.ynxbd.wx.wxfactory.bean.WxPayNotify;
 | |
| import com.ynxbd.wx.wxfactory.utils.WxRespHelper;
 | |
| import lombok.extern.slf4j.Slf4j;
 | |
| import org.apache.struts2.convention.annotation.Action;
 | |
| import org.apache.struts2.convention.annotation.Namespace;
 | |
| 
 | |
| import java.math.BigDecimal;
 | |
| import java.util.Date;
 | |
| 
 | |
| 
 | |
| /**
 | |
|  * 通知,兼容性处理
 | |
|  */
 | |
| @Slf4j
 | |
| @Namespace("/notify")
 | |
| public class NotifyAction extends BaseAction {
 | |
|     /**
 | |
|      * [微信]jsapi通知
 | |
|      *
 | |
|      * @return 是否成功
 | |
|      */
 | |
|     @Action("wx_pay_notify_servlet")
 | |
|     public Result wx_pay_notify_servlet() {
 | |
|         try {
 | |
|             WxPayNotify notifyInfo = WxPayHelper.payNotify(request);
 | |
|             Result.respXml(WxRespHelper.respOk()); // 收到请求-解析成功
 | |
| 
 | |
|             String openid = notifyInfo.getOpenid();
 | |
|             String bankTransNo = notifyInfo.getTransactionId();
 | |
|             String outTradeNo = notifyInfo.getOutTradeNo();
 | |
|             String payInfo = notifyInfo.getPayInfo();
 | |
|             BigDecimal totalFee = notifyInfo.getTotalFee();
 | |
|             String payDate = notifyInfo.getPayDate();
 | |
|             String payTime = notifyInfo.getPayTime();
 | |
| 
 | |
|             String notifyType = notifyInfo.getAttach();
 | |
| 
 | |
|             log.info("【微信】[{}]-收到通知 outTradeNo={}, bankTransNo={}", notifyType, outTradeNo, bankTransNo);
 | |
| 
 | |
|             switch (PEnum.toEnum(notifyType)) {
 | |
|                 case RECIPE:
 | |
|                     new RecipeService().recipeListPay(MerchantEnum.WX, totalFee.toString(), openid, outTradeNo, bankTransNo, null, payDate, payTime, payInfo);
 | |
|                     break;
 | |
| 
 | |
|                 case REG: // 挂号
 | |
|                     try {
 | |
|                         new RegService().regPaidNotify(MerchantEnum.WX, totalFee, openid, bankTransNo, outTradeNo, null, payDate, payTime, payInfo, new Date());
 | |
|                     } catch (ServiceException e) {
 | |
|                         log.info("【微信】[挂号]通知异常 outTradeNo={}, bankTransNo={}, message={}", outTradeNo, bankTransNo, e.getMessage());
 | |
|                     }
 | |
|                     break;
 | |
| 
 | |
|                 case IN_HOSP:
 | |
|                     boolean isInsert = new InHospService().inHospNotify(MerchantEnum.WX, openid, totalFee, outTradeNo, bankTransNo, payDate, payTime, payInfo);
 | |
|                     log.info("【微信】[住院预交金] 预存{}", (isInsert ? "成功" : "失败"));
 | |
|                     break;
 | |
| 
 | |
|                 case CASEBOOK:
 | |
|                     new CasebookService().payNotify(MerchantEnum.WX, openid, totalFee, outTradeNo, bankTransNo, payInfo);
 | |
|                     break;
 | |
| 
 | |
|                 case OUT_COLLECT:
 | |
|                     new OutCollectService().ocPayNotify(MerchantEnum.WX, openid, totalFee, outTradeNo, bankTransNo, payInfo);
 | |
|                     break;
 | |
| 
 | |
|                 default:
 | |
|                     log.info("【微信】通知类型错误,结束请求");
 | |
|                     break;
 | |
|             }
 | |
| 
 | |
|         } catch (ServiceException e) {
 | |
|             Result.respXml(WxRespHelper.resp(e)); // 收到请求-解析失败
 | |
|         }
 | |
|         return null;
 | |
|     }
 | |
| 
 | |
| 
 | |
|     /**
 | |
|      * [微信]native支付通知
 | |
|      *
 | |
|      * @return 是否成功
 | |
|      */
 | |
|     @Action("wx_native_pay_notify_servlet")
 | |
|     public Result wx_native_pay_notify_servlet() {
 | |
|         try {
 | |
|             WxPayNotify notifyInfo = WxPayHelper.payNotify(request);
 | |
|             Result.respXml(WxRespHelper.respOk()); // 收到请求-解析成功
 | |
| 
 | |
|             String openid = notifyInfo.getOpenid();
 | |
|             String bankTransNo = notifyInfo.getTransactionId();
 | |
|             String outTradeNo = notifyInfo.getOutTradeNo();
 | |
|             String payInfo = notifyInfo.getPayInfo();
 | |
|             BigDecimal totalFee = notifyInfo.getTotalFee();
 | |
| 
 | |
|             String notifyType = notifyInfo.getAttach();
 | |
| 
 | |
|             log.info("notifyInfo={}", notifyInfo);
 | |
|             log.info("【微信】[{}] native收到通知 outTradeNo={}, bankTransNo={}", notifyType, outTradeNo, bankTransNo);
 | |
| 
 | |
|             switch (PQREnum.toEnum(notifyType)) {
 | |
|                 case OUT_COLLECT:
 | |
|                     new OutCollectService().ocPayNotify(MerchantEnum.WX, openid, totalFee, bankTransNo, outTradeNo, payInfo);
 | |
|                     break;
 | |
| 
 | |
|                 default:
 | |
|                     log.info("【微信native支付】通知类型错误,结束请求");
 | |
|                     break;
 | |
|             }
 | |
| 
 | |
|         } catch (ServiceException e) {
 | |
|             Result.respXml(WxRespHelper.resp(e)); // 收到请求-解析失败
 | |
|         }
 | |
|         return null;
 | |
|     }
 | |
| }
 | |
| 
 |