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.
80 lines
3.0 KiB
80 lines
3.0 KiB
package com.ynxbd.wx.servlet;
|
|
|
|
import com.ynxbd.common.bean.enums.MerchantEnum;
|
|
import com.ynxbd.common.helper.common.HttpHelper;
|
|
import com.ynxbd.common.result.ResultEnum;
|
|
import com.ynxbd.wx.config.WeChatConfig;
|
|
import com.ynxbd.wx.wxfactory.ReqParamHelper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.slf4j.MDC;
|
|
|
|
import javax.servlet.ServletException;
|
|
import javax.servlet.annotation.WebServlet;
|
|
import javax.servlet.http.HttpServlet;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.IOException;
|
|
|
|
/**
|
|
* 多处方支付跳转
|
|
*
|
|
* @Author wsq
|
|
* @Date 2020/11/19 10:36
|
|
* @Copyright @ 2020 云南新八达科技有限公司 All rights reserved.
|
|
*/
|
|
@Slf4j
|
|
@WebServlet("/q")
|
|
public class QServlet extends HttpServlet {
|
|
|
|
@Override
|
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
MDC.remove("ip");
|
|
MDC.put("ip", HttpHelper.getIpAddress(request));
|
|
|
|
// if (StringUtils.isEmpty(userAgent)) {
|
|
// log.info(ResultEnum.PAY_TYPE_NOT_SUPPORT.message);
|
|
// HttpHelper.outRespAlert(response, ResultEnum.PAY_TYPE_NOT_SUPPORT.message);
|
|
// return;
|
|
// }
|
|
MerchantEnum merchantEnum = MerchantEnum.WX;
|
|
|
|
String userAgent = request.getHeader("user-agent");
|
|
if (!ObjectUtils.isEmpty(userAgent)) {
|
|
merchantEnum = MerchantEnum.getMerchantEnumByQr(userAgent);
|
|
if (merchantEnum == null) {
|
|
log.info(ResultEnum.PAY_TYPE_NOT_SUPPORT.message);
|
|
HttpHelper.outRespAlert(response, ResultEnum.PAY_TYPE_NOT_SUPPORT.message);
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
String patientId = request.getParameter("p");
|
|
log.info("{} [patientId={}]多张处方扫码请求,开始解析...", merchantEnum.NAME, patientId);
|
|
if (StringUtils.isEmpty(patientId)&&StringUtils.isEmpty(request.getParameter("t"))) {
|
|
log.info("[支付] 多张扫码请求 patientId is null and idCardNo is null");
|
|
return;
|
|
}
|
|
// 体检缴费,patientId赋值为0
|
|
if(!StringUtils.isEmpty(request.getParameter("t"))&&StringUtils.isEmpty(patientId)){
|
|
patientId = "0"; //patientId 赋值0
|
|
}
|
|
|
|
if (patientId.contains(".") || patientId.contains("/") || patientId.contains("http")) {
|
|
log.info("[支付] 多张扫码请求 参数无效");
|
|
return;
|
|
}
|
|
|
|
if (MerchantEnum.WX.equals(merchantEnum)) {
|
|
response.sendRedirect(WeChatConfig.getWebUrl() + "pay-qr-recipe.html?p=" + patientId + "&enp=" + ReqParamHelper.encode(patientId)+ "&ent=" + request.getParameter("t"));
|
|
}
|
|
}
|
|
|
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
doPost(request, response);
|
|
}
|
|
|
|
}
|
|
|