处方支付回调调整

master_pay
王绍全 1 week ago
parent 334be111f5
commit e76dc3245a
  1. 10
      src/main/java/com/ynxbd/common/TestA.java
  2. 13
      src/main/java/com/ynxbd/common/action/RecipeAction.java
  3. 8
      src/main/java/com/ynxbd/common/action/TreatAction.java
  4. 19
      src/main/java/com/ynxbd/common/action/pay/JYPayAction.java
  5. 2
      src/main/java/com/ynxbd/common/action/pay/MedicalTestAction.java
  6. 14
      src/main/java/com/ynxbd/common/action/pay/NotifyAction.java
  7. 14
      src/main/java/com/ynxbd/common/action/pay/WxPayAction.java
  8. 10
      src/main/java/com/ynxbd/common/action/test/TestAction.java
  9. 4
      src/main/java/com/ynxbd/common/action/xk/XKAction.java
  10. 25
      src/main/java/com/ynxbd/common/bean/HisRecipe.java
  11. 5
      src/main/java/com/ynxbd/common/bean/enums/MerchantEnum.java
  12. 2
      src/main/java/com/ynxbd/common/bean/xk/HisTCMRxItem.java
  13. 3
      src/main/java/com/ynxbd/common/bean/xk/HisWMRxItem.java
  14. 2
      src/main/java/com/ynxbd/common/dao/his/HisTreatDao.java
  15. 9
      src/main/java/com/ynxbd/common/dao/his/HisXKDao.java
  16. 27
      src/main/java/com/ynxbd/common/helper/common/JsonHelper.java
  17. 7
      src/main/java/com/ynxbd/common/service/MicroService.java
  18. 3
      src/main/java/com/ynxbd/common/service/PayService.java
  19. 9
      src/main/java/com/ynxbd/common/service/RxService.java
  20. 3
      src/main/java/com/ynxbd/jy/helper/JYPayConfig.java
  21. 4
      src/main/java/com/ynxbd/jy/helper/JYPayHelper.java
  22. 8
      src/main/java/com/ynxbd/wx/servlet/oldpay/PayNotifyServlet.java
  23. 135
      src/main/java/com/ynxbd/wx/wxfactory/utils/WxNotifyResp.java
  24. 2
      src/main/resources/jy-config.xml

File diff suppressed because one or more lines are too long

@ -101,8 +101,10 @@ public class RecipeAction extends BaseAction {
rxItem.setPid(patientId);
rxItem.setTreatNum(rxItem.getMzNum());
rxItem.setEnTreatNum(AesWxHelper.encode(rxItem.getTreatNum()));
if (rxItem.getDate() != null && DateHelper.inDateRange(begDate, endDate, rxItem.getDate(), DateHelper.DateEnum.yyyy_MM_dd)
&& !"1".equals(rxItem.getSTDFlag()) && (!"1".equals(rxItem.getInternetHospFlag()) || "1".equals(rxItem.getYJSAuditFlag()))) {
if (rxItem.getDate() != null
&& DateHelper.inDateRange(begDate, endDate, rxItem.getDate(), DateHelper.DateEnum.yyyy_MM_dd)
&& !rxItem.hasRxCirculation() // 不是双通道处方
&& (!rxItem.hasOLRx() || rxItem.hasOLRxAndExamine())) { // 不是互联网处方 || 是互联网处方且已审核
dataList.add(rxItem);
}
}
@ -124,7 +126,8 @@ public class RecipeAction extends BaseAction {
List<HisRecipe> resultList = new ArrayList<>();
for (HisRecipe hisRecipe : hisRecipes) {
if (hisRecipe.getDate() != null && DateHelper.inDateRange(begDate, endDate, hisRecipe.getDate(), DateHelper.DateEnum.yyyy_MM_dd)
&& !"1".equals(hisRecipe.getSTDFlag()) && (!"1".equals(hisRecipe.getInternetHospFlag()) || "1".equals(hisRecipe.getYJSAuditFlag()))) {
&& !"1".equals(hisRecipe.getSTDFlag())
&& (!"1".equals(hisRecipe.getInternetHospFlag()) || "1".equals(hisRecipe.getYJSAuditFlag()))) {
resultList.add(hisRecipe);
}
}
@ -152,7 +155,9 @@ public class RecipeAction extends BaseAction {
rxItem.setPid(patientId);
rxItem.setTreatNum(rxItem.getMzNum());
rxItem.setEnTreatNum(AesWxHelper.encode(rxItem.getTreatNum()));
if (rxItem.getDate() != null && DateHelper.inDateRange(begDate, endDate, rxItem.getDate(), DateHelper.DateEnum.yyyy_MM_dd)) {
if (rxItem.getDate() != null
&& DateHelper.inDateRange(begDate, endDate, rxItem.getDate(), DateHelper.DateEnum.yyyy_MM_dd)
&& rxItem.hasOLRx()) { // 是互联网处方
dataList.add(rxItem);
}
}

@ -112,14 +112,14 @@ public class TreatAction extends BaseAction {
@Action("queryTreatByTreatNum")
public Result queryTreatByTreatNum(@AesDecode(AesClass = AesMicroHelper.class) String treatNum) {
@Action("queryHisTreatByTreatNum")
public Result queryHisTreatByTreatNum(@AesDecode String treatNum) {
try {
log.info("[就诊记录]查询信息 treatNum={}", treatNum);
log.info("[就诊记录]查询 treatNum={}", treatNum);
if (ObjectUtils.isEmpty(treatNum)) {
return Result.error(ResultEnum.PARAM_IS_INVALID);
}
List<HisTreat> daatList = new HisTreatDao().queryTreatByTreatNum(treatNum);
List<HisTreat> daatList = new HisTreatDao().queryHisTreatByTreatNum(treatNum);
return Result.success(daatList);
} catch (ServiceException e) {
return Result.error(e);

@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
import com.ynxbd.common.action.base.BaseAction;
import com.ynxbd.common.bean.enums.MerchantEnum;
import com.ynxbd.common.bean.pay.ApiPayNotify;
import com.ynxbd.common.bean.pay.Order;
import com.ynxbd.common.bean.pay.ReqOrder;
import com.ynxbd.common.helper.common.HttpHelper;
import com.ynxbd.common.helper.common.JsonHelper;
@ -12,17 +11,10 @@ import com.ynxbd.common.result.Result;
import com.ynxbd.common.result.ResultEnum;
import com.ynxbd.common.result.ServiceException;
import com.ynxbd.common.service.PayService;
import com.ynxbd.common.service.RegService;
import com.ynxbd.common.service.RxService;
import com.ynxbd.jy.bean.JYOrder;
import com.ynxbd.jy.bean.JYPayNotify;
import com.ynxbd.jy.bean.JYPayRSAUtil;
import com.ynxbd.jy.bean.enums.JYBusinessTypeEnum;
import com.ynxbd.jy.bean.enums.JYOrderTypeEnum;
import com.ynxbd.jy.helper.JYPayConfig;
import com.ynxbd.jy.helper.JYPayHelper;
import com.ynxbd.wx.wxfactory.WxPayHelper;
import com.ynxbd.wx.wxfactory.utils.WxRespHelper;
import com.ynxbd.wx.wxfactory.utils.WxNotifyResp;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.struts2.convention.annotation.Action;
@ -114,10 +106,11 @@ public class JYPayAction extends BaseAction {
*/
@Action("notify")
public Result notify(String notifyType) {
WxNotifyResp notify = new WxNotifyResp(MerchantEnum.JY);
try {
PEnum pEnum = PEnum.findEnum(notifyType);
if (pEnum == null) {
return Result.respXml(WxRespHelper.respOk());
return Result.respXml(notify.respOk());
}
Map<String, String> params = reqParamsToMap();
@ -129,15 +122,15 @@ public class JYPayAction extends BaseAction {
ApiPayNotify info = JYPayHelper.jyPayNotify(params, notifyType);
log.info("【京颐】[{}]收到[{}]通知-{}", pEnum.NAME, (info.isRefundOrder() ? "退款" : "支付"), JsonHelper.toJsonString(info));
Result.respXml(WxRespHelper.respOk()); // 收到请求-解析成功
Result.respXml(notify.respOk()); // 收到请求-解析成功
if (info.isRefundOrder()) {
PayService.refundNotify(info);
} else {
PayService.wxNotify(info);
PayService.wxNotify(notify.merchantEnum, info);
}
} catch (ServiceException e) {
Result.respXml(WxRespHelper.resp(e)); // 收到请求-解析失败
Result.respXml(notify.resp(e)); // 收到请求-解析失败
}
return null;
}

@ -237,7 +237,7 @@ public class MedicalTestAction extends BaseAction {
recipe.setTreatNum(treatNum);
if (treatNum != null) {
List<HisTreat> dataList = new HisTreatDao().queryTreatByTreatNum(treatNum);
List<HisTreat> dataList = new HisTreatDao().queryHisTreatByTreatNum(treatNum);
if (!dataList.isEmpty()) {
HisTreat hisTreat = dataList.get(0);
if (hisTreat != null) {

@ -8,7 +8,7 @@ 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.utils.WxRespHelper;
import com.ynxbd.wx.wxfactory.utils.WxNotifyResp;
import lombok.extern.slf4j.Slf4j;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
@ -29,13 +29,14 @@ public class NotifyAction extends BaseAction {
*/
@Action("wx_pay_notify_servlet")
public Result wx_pay_notify_servlet() {
WxNotifyResp notify = new WxNotifyResp(MerchantEnum.WX);
try {
ApiPayNotify info = WxPayHelper.wxPayNotify(request);
Result.respXml(WxRespHelper.respOk()); // 收到请求-解析成功
Result.respXml(notify.respOk()); // 收到请求-解析成功
PayService.wxNotify(info);
PayService.wxNotify(notify.merchantEnum, info);
} catch (ServiceException e) {
Result.respXml(WxRespHelper.resp(e)); // 收到请求-解析失败
Result.respXml(notify.resp(e)); // 收到请求-解析失败
}
return null;
}
@ -48,9 +49,10 @@ public class NotifyAction extends BaseAction {
*/
@Action("wx_native_pay_notify_servlet")
public Result wx_native_pay_notify_servlet() {
WxNotifyResp notify = new WxNotifyResp(MerchantEnum.WX);
try {
ApiPayNotify info = WxPayHelper.wxPayNotify(request);
Result.respXml(WxRespHelper.respOk()); // 收到请求-解析成功
Result.respXml(notify.respOk()); // 收到请求-解析成功
String openid = info.getOpenId();
String bankTransNo = info.getTransactionId();
@ -73,7 +75,7 @@ public class NotifyAction extends BaseAction {
}
} catch (ServiceException e) {
Result.respXml(WxRespHelper.resp(e)); // 收到请求-解析失败
Result.respXml(notify.resp(e)); // 收到请求-解析失败
}
return null;
}

@ -9,7 +9,7 @@ import com.ynxbd.common.result.ServiceException;
import com.ynxbd.common.service.OutCollectService;
import com.ynxbd.common.service.PayService;
import com.ynxbd.wx.wxfactory.WxPayHelper;
import com.ynxbd.wx.wxfactory.utils.WxRespHelper;
import com.ynxbd.wx.wxfactory.utils.WxNotifyResp;
import lombok.extern.slf4j.Slf4j;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
@ -27,13 +27,14 @@ public class WxPayAction extends BaseAction {
*/
@Action("apiNotify")
public Result apiNotify() {
WxNotifyResp notify = new WxNotifyResp(MerchantEnum.WX);
try {
ApiPayNotify info = WxPayHelper.wxPayNotify(request);
Result.respXml(WxRespHelper.respOk()); // 收到请求-解析成功
Result.respXml(notify.respOk()); // 收到请求-解析成功
PayService.wxNotify(info);
PayService.wxNotify(notify.merchantEnum, info);
} catch (ServiceException e) {
Result.respXml(WxRespHelper.resp(e)); // 收到请求-解析失败
Result.respXml(notify.resp(e)); // 收到请求-解析失败
}
return null;
}
@ -46,9 +47,10 @@ public class WxPayAction extends BaseAction {
*/
@Action("nativeNotify")
public Result nativeNotify() {
WxNotifyResp notify = new WxNotifyResp(MerchantEnum.WX);
try {
ApiPayNotify info = WxPayHelper.wxPayNotify(request);
Result.respXml(WxRespHelper.respOk()); // 收到请求-解析成功
Result.respXml(notify.respOk()); // 收到请求-解析成功
String openid = info.getOpenId();
String bankTransNo = info.getTransactionId();
@ -71,7 +73,7 @@ public class WxPayAction extends BaseAction {
}
} catch (ServiceException e) {
Result.respXml(WxRespHelper.resp(e)); // 收到请求-解析失败
Result.respXml(notify.resp(e)); // 收到请求-解析失败
}
return null;
}

@ -38,9 +38,17 @@ public class TestAction extends BaseAction {
}
}
// public synchronized void jy_refund_handle() {
// if (i == 0) {
// i++;
// JYPayHelper.refundPayOrder(JYBusinessTypeEnum.B102, new ReqOrder(), outRefundNo, refundFee, outTradeNo, bankMerchantNo, tradeNo);
// }
// }
@Action("refund_test")
public Result refund_test() throws ServiceException {
refund_handle();
// refund_handle();
// jy_refund_handle();
return Result.success();
}

@ -154,7 +154,7 @@ public class XKAction extends BaseAction {
*/
@Action("queryOLRegConsultFee")
public Result queryOLRegConsultFee(String code) {
log.info("[问诊]查询问诊挂号-咨询费用 code={}", code);
log.info("[问诊]查询问诊挂号-咨询费用");
try {
return Result.success(new HisTreatDao().queryOLRegConsultFee(code));
} catch (Exception e) {
@ -169,7 +169,7 @@ public class XKAction extends BaseAction {
*/
@Action("queryOLRegRevisitFee")
public Result queryOLRegRevisitFee(String code) {
log.info("[问诊]查询问诊挂号-复诊费用 code={}", code);
log.info("[问诊]查询问诊挂号-复诊费用");
try {
return Result.success(new HisTreatDao().queryOLRegRevisitFee(code));
} catch (Exception e) {

@ -65,23 +65,22 @@ public class HisRecipe {
private String hospitalAreaCode;
// 院区名称
private String hospitalAreaName;
// 互联网医院处方标识[1:互联网处方]
private String internetHospFlag;
// 是否为双通道处方 [1:双通道处方]
private String sTDFlag;
//
private String sTDUploadDate;
// 处方是否已经审核
private String yJSAuditFlag;
private String ybAttrib; // 医保属性[4:为慢性病,5:为特殊病]
private Integer ybJsFlag; // 是否允许医保支付 [1不允许医保缴费,否则允许医保缴费]
private Integer ybJsFlag; // 是否禁用医保支付 [1不允许医保缴费,否则允许医保缴费]
private String ybBZCode; // 病种编码
private String ybBZCode; // 医保病种编码
private String ybBZName; // 病种名称
private String ybBZName; // 医保病种名称
// 发票号(已缴费中查询出来=>发票状态)
private String invoiceNo;
@ -104,4 +103,20 @@ public class HisRecipe {
}
this.enBillNo = AesWxHelper.encode(this.billNo);
}
// 为双通道处方
public boolean hasRxCirculation() {
return "1".equals(this.sTDFlag);
}
// 为互联网问诊处方
public boolean hasOLRx() {
return "1".equals(this.internetHospFlag);
}
// 为互联网处方且已审核
public boolean hasOLRxAndExamine() {
return "1".equals(this.internetHospFlag) && "1".equals(this.yJSAuditFlag);
}
}

@ -40,7 +40,7 @@ public enum MerchantEnum {
"0", "1", "2"),
// Global Medical Communities
WX_GMC("wx_gmc_mini", "【微信医共体】", WeChatConfig.GMC_MINI_APP_ID, "WMC",
WX_GMC("wx_gmc_mini", "【微信医共体】", WeChatConfig.GMC_MINI_APP_ID, "WG",
WX.IS_DEV,
WX.HIS_PAY_WAY,
WX.BAR_CODE_RULES,
@ -194,6 +194,9 @@ public enum MerchantEnum {
} else if (MerchantEnum.BCM.OUT_TRADE_NO_PREFIX.toUpperCase().equals(outTradeNo.substring(0, MerchantEnum.BCM.OUT_TRADE_NO_PREFIX.length()))) {
return MerchantEnum.BCM;
} else if (MerchantEnum.JY.OUT_TRADE_NO_PREFIX.toUpperCase().equals(outTradeNo.substring(0, MerchantEnum.JY.OUT_TRADE_NO_PREFIX.length()))) {
return MerchantEnum.JY;
} else {
return null;
}

@ -31,4 +31,6 @@ public class HisTCMRxItem implements Serializable {
@JSONField(ordinal = 5, name = "NOTE")
private String note;
@JSONField(ordinal = 6, name = "XMPRICE")
private String xmPrice;
}

@ -53,4 +53,7 @@ public class HisWMRxItem implements Serializable {
@JSONField(ordinal = 12, name = "NOTE")
private String note;
@JSONField(ordinal = 13, name = "XMPRICE")
private String xmPrice;
}

@ -98,7 +98,7 @@ public class HisTreatDao {
}
public List<HisTreat> queryTreatByTreatNum(String treatNum) throws ServiceException {
public List<HisTreat> queryHisTreatByTreatNum(String treatNum) throws ServiceException {
List<HisTreat> dataList = new ArrayList<>();
JsonResult jsonResult = HisFactory.His().getJsonResult(HisEnum.XK_QUERY_TREAT, params -> {

@ -7,9 +7,9 @@ import com.ynxbd.common.helper.common.JsonHelper;
import com.ynxbd.common.his.HisEnum;
import com.ynxbd.common.his.HisFactory;
import com.ynxbd.common.result.JsonResult;
import com.ynxbd.common.result.Result;
import com.ynxbd.common.result.ResultEnum;
import com.ynxbd.common.result.ServiceException;
import com.ynxbd.jy.helper.JYPayConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
@ -120,6 +120,7 @@ public class HisXKDao {
rxList = hisTCMRxItems;
}
JsonResult jsonResult = HisFactory.His().getJsonResult(HisEnum.HIS_XK_RX_CREATE, params -> {
params.put("MZNum", treatNum); // 门诊号
params.put("CFFlag", rxDrugType); // 处方药品类别[1:西药处方;2:中药处方]
@ -137,7 +138,11 @@ public class HisXKDao {
params.put("CFCount", tcmCFCount); // 处方付数
params.put("CFUseCount", tcmCFUseCount); // 处方单付使用次数
params.put("UseCountForDay", tcmUseCountForDay); // 每日使用次数
params.put("Jarray", JsonHelper.toJsonStringEmpty(rxList));
if (JYPayConfig.IS_ENABLE) {
params.put("Jarray", JsonHelper.toJsonStringEmpty(rxList));
} else {
params.put("Jarray", JsonHelper.toJsonStringEmpty(rxList, "XMPRICE"));
}
});
log.info("[开方]返回: {}", JsonHelper.toJsonString(jsonResult.getDataMap()));
return jsonResult;

@ -6,12 +6,15 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.serializer.PascalNameFilter;
import com.alibaba.fastjson.serializer.PropertyFilter;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.serializer.ValueFilter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
@ -30,22 +33,36 @@ public class JsonHelper {
return JSON.toJSONString(data);
}
/**
* 对象转JSON[空值转空字符串]
* 象转JSON[空值转空字符串]
*
* @param data data
* @param data 数据
* @param filterKeys 需要移除不输出的key
* @return json
*/
public static String toJsonStringEmpty(Object data) {
ValueFilter nullToEmptyFilter = (object, name, value) -> {
public static String toJsonStringEmpty(Object data, String... filterKeys) {
List<String> filterKeyList = filterKeys == null ? Collections.emptyList() : Arrays.asList(filterKeys);
PropertyFilter propertyFilter = (source, name, value) -> { // 控制字段是否输出:value是null → 返回false,不输出这个key
return !filterKeyList.contains(name);
};
ValueFilter valueFilter = (object, name, value) -> { // null转为""
if (value == null) {
return "";
}
return value;
};
return JSON.toJSONString(data, nullToEmptyFilter, SerializerFeature.WriteNonStringKeyAsString, SerializerFeature.WriteMapNullValue);
return JSON.toJSONString(data,
new com.alibaba.fastjson.serializer.SerializeFilter[]{propertyFilter, valueFilter},
SerializerFeature.WriteNonStringKeyAsString,
SerializerFeature.WriteMapNullValue
);
}
/**
* 支持返回大写json
*

@ -16,9 +16,6 @@ import java.util.ArrayList;
import java.util.List;
/**
* @author 李进才
* @ClassName MicroService
* @Description description
* @date 2023/4/10 15:22
*/
@Slf4j
@ -62,11 +59,11 @@ public class MicroService {
String deptName = rx.getDeptName();
String bankTransNo = rx.getBankTransNo();
if (StrUtil.hasBlank(openId, patientId, treatNum, deptCode, deptName, bankTransNo)) {
log.warn("[监管平台]查询HIS患者信息失败 openId={}, patientId={}, treatNum={}, deptCode={}, deptName={}, bankTransNo={}",
openId, patientId, treatNum, deptCode, deptName, bankTransNo);
log.warn("[监管平台]查询HIS患者信息失败 openId={}, patientId={}, treatNum={}, deptCode={}, deptName={}, bankTransNo={}", openId, patientId, treatNum, deptCode, deptName, bankTransNo);
return;
}
log.info("[监管平台]查询患者信息 openId={}, patientId={}", openId, patientId);
Patient patient = new PatientService().queryByOpenIdAndEPId(openId, patientId);
if (patient == null) {
patient = new PatientService().queryHisPatientByPatientId(patientId);

@ -47,7 +47,7 @@ public class PayService {
*
* @param info 回调信息
*/
public static void wxNotify(ApiPayNotify info) throws ServiceException {
public static void wxNotify(MerchantEnum mchEnum, ApiPayNotify info) throws ServiceException {
String openid = info.getOpenId();
String bankTransNo = info.getTransactionId();
String outTradeNo = info.getOutTradeNo();
@ -58,7 +58,6 @@ public class PayService {
String notifyType = info.getAttach();
MerchantEnum mchEnum = MerchantEnum.findEnumByOutTradeNo(outTradeNo);
if (mchEnum == null) {
mchEnum = MerchantEnum.WX;
}

@ -288,6 +288,7 @@ public class RxService {
public boolean hisRxListPay(MerchantEnum merchantEnum, String totalFee, String openid, String outTradeNo, String bankTransNo, String bankMerchantNo, String payDate, String payTime, String payInfo) {
RxDao rxDao = new RxDao();
// 此处判断是否已经发起缴费,只要已存在数据库记录,说明已经发起了缴费请求,不能根据已经缴费成功,才取消本次缴费请求,因为请求可能已经延时,本次请求可能是重复提交的请求
if (PayService.hasUserOrderNo(outTradeNo, openid)) {
log.info("{} [处方]已发起缴费 outTradeNo={}", merchantEnum.NAME, outTradeNo);
@ -361,6 +362,11 @@ public class RxService {
return true;
}
if (MerchantEnum.JY.equals(merchantEnum)) {
new MicroService().uploadRxFee(rxList, failedList.isEmpty(), new BigDecimal(totalFee), false);
return true;
}
// 处理his缴费失败的处方
String failedRecipeId, errorCode, errorMsg, refundDesc;
// 调用超时处方
@ -392,9 +398,6 @@ public class RxService {
TZReserveConfig.reserveRun(patientId); // 天助医技预约
}
if (MerchantEnum.JY.equals(merchantEnum)) {
new MicroService().uploadRxFee(rxList, failedList.isEmpty(), new BigDecimal(totalFee), false);
}
new HealthUploadService().rxReportHISData(merchantEnum, openid, patientId);
return true;

@ -10,6 +10,7 @@ public class JYPayConfig {
// 请求地址
public final static String URL;
public final static boolean IS_ENABLE;
// 应用编号
public final static String APPLICATION_ID;
@ -24,6 +25,8 @@ public class JYPayConfig {
static {
XmlConfigHelper config = new XmlConfigHelper().read("jy-config.xml", "pay");
IS_ENABLE = config.getBoolean("is_enable", false);
config.setIsEnable(IS_ENABLE);
URL = config.getString("url");
APPLICATION_ID = config.getString("application_id");

@ -11,12 +11,15 @@ import com.ynxbd.common.helper.common.DateHelper;
import com.ynxbd.common.helper.common.JsonHelper;
import com.ynxbd.common.helper.http.OkHttpHelper;
import com.ynxbd.common.helper.rsa.RSAHelper;
import com.ynxbd.common.result.ResultEnum;
import com.ynxbd.common.result.ServiceException;
import com.ynxbd.jy.bean.JYOrder;
import com.ynxbd.jy.bean.JYPayNotify;
import com.ynxbd.jy.bean.JYResult;
import com.ynxbd.jy.bean.enums.JYBusinessTypeEnum;
import com.ynxbd.wx.config.WeChatConfig;
import com.ynxbd.wx.wxfactory.utils.WxSignHelper;
import com.ynxbd.wx.wxfactory.utils.XmlHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
@ -447,4 +450,5 @@ public class JYPayHelper {
dateMap.put(TIME_KEY, new SimpleDateFormat("HH:mm:ss").format(date));
return dateMap;
}
}

@ -7,7 +7,7 @@ import com.ynxbd.common.result.Result;
import com.ynxbd.common.result.ServiceException;
import com.ynxbd.common.service.RxService;
import com.ynxbd.wx.wxfactory.WxPayHelper;
import com.ynxbd.wx.wxfactory.utils.WxRespHelper;
import com.ynxbd.wx.wxfactory.utils.WxNotifyResp;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
@ -36,10 +36,10 @@ public class PayNotifyServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
MDC.remove("ip");
MDC.put("ip", HttpHelper.getIpAddress(request));
WxNotifyResp notify = new WxNotifyResp(MerchantEnum.WX);
try {
ApiPayNotify info = WxPayHelper.wxPayNotify(request);
Result.respXml(response, WxRespHelper.respOk()); // 收到请求-解析成功
Result.respXml(response, notify.respOk()); // 收到请求-解析成功
String openid = info.getOpenId();
String bankTransNo = info.getTransactionId();
@ -54,7 +54,7 @@ public class PayNotifyServlet extends HttpServlet {
new RxService().hisRxListPay(MerchantEnum.WX, totalFee.toString(), openid, outTradeNo, bankTransNo, null, payDate, payTime, payInfo);
} catch (ServiceException e) {
Result.respXml(response, WxRespHelper.resp(e)); // 收到请求-解析成功
Result.respXml(response, notify.resp(e)); // 收到请求-解析成功
}
}

@ -1,64 +1,71 @@
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);
// }
}
package com.ynxbd.wx.wxfactory.utils;
import com.ynxbd.common.bean.enums.MerchantEnum;
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 WxNotifyResp {
public WxNotifyResp(MerchantEnum merchantEnum) {
this.merchantEnum = merchantEnum;
}
public final MerchantEnum merchantEnum;
/**
* 成功相应
*/
public String resp(ServiceException e) {
if (ResultEnum.PAY_NOTIFY_REPEAT.equals(e.getResultEnum())) {
return respOk();
}
return respFail(e.getMessage());
}
/**
* 成功响应
*/
public String respOk() {
log.info("【{}】通知成功", this.merchantEnum.NAME);
try {
Map<String, Object> map = new HashMap<>();
map.put("return_code", "SUCCESS");
map.put("return_msg", "OK");
return XmlHelper.mapToXml(map);
} catch (Exception e) {
log.error("", e);
}
return null;
}
/**
* 失败响应
*/
private String respFail(String message) {
log.info("【{}】回调通知: {}", this.merchantEnum.NAME, 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) {
log.error("", e);
}
return null;
}
// public static void main(String[] args) throws DocumentException {
//
// TestPay testPay = XmlHelper.xmlToBean(xml, TestPay.class);
// System.out.println(testPay);
// }
}

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<config>
<pay name="[京颐]支付配置">
<is_enable>true</is_enable>
<url>http://192.168.1.26:8083</url>
<application_id name="应用编号">30007</application_id>
<merchant_id name="应用商户编号">20007</merchant_id>
@ -8,5 +9,4 @@
<public_key>MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD1eiOktZm8bUwjHA2bFlrULg9v/VAmBfUWb8/1+xyZH5eSa7itvAG2Kdzv7L59nRIspXyO6ZW+gGmofnX8CqI5ofLrpissgoqZadNfz5v/k2Q78YTBM8BEMwkrPwOsbFX62poPSKr4kZRHgMADJkgS6AhsaDNBLdH6uRE8R0H6lQIDAQAB</public_key>
<private_key>MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAPV6I6S1mbxtTCMcDZsWWtQuD2/9UCYF9RZvz/X7HJkfl5JruK28AbYp3O/svn2dEiylfI7plb6Aaah+dfwKojmh8uumKyyCiplp01/Pm/+TZDvxhMEzwEQzCSs/A6xsVframg9IqviRlEeAwAMmSBLoCGxoM0Et0fq5ETxHQfqVAgMBAAECgYAf8F9Y2+P/1zyzyL+gcR0qRD/v80aNW/MSk0O8noqPBcRD4c4qlK6oU/QSJ3x1fY1Sz8lQEuZP3gdhS+rv+zY2BjbfSq4HcZexmbBmh0NQ4Swd7i0hfkSM+koHZjVoPY/FJ/TW/Ks3iV+kpAZuVLCh60B66H8y9K5xu331nLxeYQJBAPzFeQPVJThxIBbk5g8/fYD/gbglEGqdurTJlo9tmCuqzty19fApBE+41ir9Sl2vguDnY1d9Zbuf1AlS21jsVx0CQQD4nNC1FyDKK6GxQvOm6Do+b663ft0WK7dum0c4pM57VPTRqxag4p6lYCu5KYmVvUL20KGE5LVZ9LaOIMIurD/ZAkEA4z4My1tFuPZKqQpjoXWsuNn7nrcDiTX/8iQBDTSzxx4qFtYnIh9d1uYO9Fr+DjeJa/PZpYAAg6rujutEcy8WKQJARir0WPgjIAx6gW5VGHmY3sBkvpOG0Ngb2JLo4hrZ0ENlKbwxEc2EW0aucH9BvsqBGOo/fCOU78O6tpiWVdf12QJAP8ENPIBQCLwHq0U5bzV+X94BmuOfTAqwvy/r6XQcOct0k/M/Lln0FUcPwAb6rl/1R55Xj1/DxI2UbTc4KNNpng==</private_key>
</pay>
</config>

Loading…
Cancel
Save