parent
70fbcfefe3
commit
3b61627b61
31 changed files with 901 additions and 576 deletions
@ -1,13 +1,61 @@ |
|||||||
package com.ynxbd.common; |
package com.ynxbd.common; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.ynxbd.common.bean.pay.PEISOrderInfo; |
||||||
|
import com.ynxbd.common.helper.common.Base64Helper; |
||||||
|
import com.ynxbd.common.helper.common.JsonHelper; |
||||||
|
import com.ynxbd.common.helper.http.OkHttpHelper; |
||||||
|
import com.ynxbd.common.result.JsonResult; |
||||||
|
import com.ynxbd.common.result.Result; |
||||||
|
import com.ynxbd.wx.config.WeChatConfig; |
||||||
import com.ynxbd.wx.utils.DesEncryptHelper; |
import com.ynxbd.wx.utils.DesEncryptHelper; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import okhttp3.FormBody; |
||||||
|
import okhttp3.RequestBody; |
||||||
|
import org.apache.commons.lang3.ObjectUtils; |
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException; |
||||||
|
import java.net.URLDecoder; |
||||||
|
|
||||||
|
|
||||||
|
@Slf4j |
||||||
public class TestA { |
public class TestA { |
||||||
|
|
||||||
|
public static void main(String[] args) throws UnsupportedEncodingException { |
||||||
|
|
||||||
|
// String a = "";
|
||||||
|
// String s = DesEncryptHelper.deCode(a);
|
||||||
|
// System.out.println(s);
|
||||||
|
|
||||||
|
// RequestBody requestBody = new FormBody.Builder()
|
||||||
|
// .add("token", "")
|
||||||
|
// .add("state", "aHR0cCUzQSUyRiUyRnNseGxmd3N5LnNseHJteXkuY24lMkZ3eCUyRndlYiUyRnJlZy1yZXNlcnZlLmh0bWwlMjMlMkY=")
|
||||||
|
// .add("isUserInfo", "false")
|
||||||
|
// .add("enuId", "false")
|
||||||
|
// .add("protocolState", "0")
|
||||||
|
// .build();
|
||||||
|
// log.info("[认证请求转发] resp:[{}]", requestBody);
|
||||||
|
// log.info("[认证请求转发] resp:[{}]", JsonHelper.toJsonString(requestBody));
|
||||||
|
|
||||||
|
|
||||||
|
// String data = OkHttpHelper.postFormStr("http://slxlfwsy.slxrmyy.cn/wx/wx_auth/is_auth", map -> {
|
||||||
|
// map.put("token", null);
|
||||||
|
// map.put("state", "aHR0cCUzQSUyRiUyRnNseGxmd3N5LnNseHJteXkuY24lMkZ3eCUyRndlYiUyRnJlZy1yZXNlcnZlLmh0bWwlMjMlMkY=");
|
||||||
|
// map.put("isUserInfo", false);
|
||||||
|
// map.put("enuId", false);
|
||||||
|
// map.put("protocolState", 0);
|
||||||
|
// }, null);
|
||||||
|
|
||||||
|
// String data = OkHttpHelper.post("http://www.slxrmyy.cn/wx/wx_auth/is_auth", requestBody);
|
||||||
|
// JSONObject jsonObject = JsonHelper.parseObject(data);
|
||||||
|
// System.out.println(JsonHelper.toJsonString(jsonObject));
|
||||||
|
|
||||||
|
//
|
||||||
|
// String state = "aHR0cCUzQSUyRiUyRnNseGxmd3N5LnNseHJteXkuY24lMkZ3eCUyRndlYiUyRnJlZy1yZXNlcnZlLmh0bWwlMjMlMkY=";
|
||||||
|
// String decode = URLDecoder.decode(Base64Helper.decode(state), "UTF-8");
|
||||||
|
// System.out.println(decode);
|
||||||
|
|
||||||
public static void main(String[] args) { |
|
||||||
String a = ""; |
|
||||||
String s = DesEncryptHelper.deCode(a); |
|
||||||
System.out.println(s); |
|
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
} |
} |
||||||
|
|||||||
@ -0,0 +1,25 @@ |
|||||||
|
package com.ynxbd.common.action.weihu; |
||||||
|
|
||||||
|
import com.ynxbd.common.bean.pay.Order; |
||||||
|
import com.ynxbd.common.dao.RecipeDao; |
||||||
|
import com.ynxbd.common.result.Result; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.apache.struts2.convention.annotation.Action; |
||||||
|
import org.apache.struts2.convention.annotation.Namespace; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
|
||||||
|
@Slf4j |
||||||
|
@Namespace("/data_wh") |
||||||
|
public class DataWHAction { |
||||||
|
|
||||||
|
|
||||||
|
@Action("getData") |
||||||
|
public Result getData(String callNo) { |
||||||
|
String begTime = "2025-10-27"; |
||||||
|
String endTime = "2025-12-08"; |
||||||
|
return Result.success(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,47 @@ |
|||||||
|
package com.ynxbd.common.bean.pay; |
||||||
|
|
||||||
|
import lombok.Getter; |
||||||
|
import lombok.NoArgsConstructor; |
||||||
|
import lombok.Setter; |
||||||
|
import lombok.ToString; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
@ToString |
||||||
|
@NoArgsConstructor |
||||||
|
public class PEISOrderInfo implements Serializable { |
||||||
|
private static final long serialVersionUID = 20251217160400001L; |
||||||
|
|
||||||
|
private Long id; |
||||||
|
|
||||||
|
private Long eid; |
||||||
|
|
||||||
|
private String createTime; |
||||||
|
// 交易时间
|
||||||
|
private String payTime; |
||||||
|
|
||||||
|
private String payStatus; |
||||||
|
|
||||||
|
// 订单金额
|
||||||
|
private BigDecimal fee; |
||||||
|
// 体检订单号
|
||||||
|
private String orderNo; |
||||||
|
// 是否删除-标识体检的订单是否已退费(true:删除;false:未删除)
|
||||||
|
private Boolean isDeleted; |
||||||
|
// 微信是否支付(true:已支付,false:未支付)
|
||||||
|
private Boolean isWxPay; |
||||||
|
// HIS是否记账(true:已记账,false:未记账)
|
||||||
|
private Boolean isCost; |
||||||
|
// 退费状态
|
||||||
|
private String refundStatus; |
||||||
|
// 退费时间
|
||||||
|
private String refundTime; |
||||||
|
|
||||||
|
// 是否已退费成功
|
||||||
|
public boolean hasRefundOK() { |
||||||
|
return "OK".equals(refundStatus); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,25 @@ |
|||||||
|
package com.ynxbd.common.bean.pay; |
||||||
|
|
||||||
|
import lombok.Getter; |
||||||
|
import lombok.NoArgsConstructor; |
||||||
|
import lombok.Setter; |
||||||
|
import lombok.ToString; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 体检预约 |
||||||
|
* |
||||||
|
* @Author wsq |
||||||
|
* @Date 2020/11/12 10:24 |
||||||
|
* @Copyright @ 2020 云南新八达科技有限公司 All rights reserved. |
||||||
|
*/ |
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
@ToString(callSuper = true) |
||||||
|
@NoArgsConstructor |
||||||
|
public class PEISReserve extends Order implements Serializable { |
||||||
|
private static final long serialVersionUID = 202512171006000001L; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,114 @@ |
|||||||
|
package com.ynxbd.common.dao.peis; |
||||||
|
|
||||||
|
import com.ynxbd.common.bean.pay.PEISReserve; |
||||||
|
import com.ynxbd.common.config.db.DataBase; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @author 李进才 |
||||||
|
* @ClassName PeisDao |
||||||
|
* @Description TODO |
||||||
|
* @date 2023/11/16 15:43:00 |
||||||
|
*/ |
||||||
|
public class PEISDao { |
||||||
|
/** |
||||||
|
* 处方支付,数据预存(单个) |
||||||
|
* |
||||||
|
* @param info 支付信息 |
||||||
|
* @return 是否存储成功 |
||||||
|
*/ |
||||||
|
public boolean insert(PEISReserve info) { |
||||||
|
String sql = "insert into peis_reserve(updateTime, noticeStatus, payStatus, openId, patientId, payMoney, totalFee, outTradeNo, noticeOrderNo, treatNum) values (now(),?,?,?,?,?,?,?,?,?)"; |
||||||
|
return DataBase.insert(sql, ps -> { |
||||||
|
ps.setInt(1, info.getPayStatus()); |
||||||
|
ps.setInt(2, info.getNoticeStatus()); |
||||||
|
ps.setString(3, info.getOpenid()); |
||||||
|
ps.setString(4, info.getPatientId()); |
||||||
|
ps.setBigDecimal(5, info.getTotalFee()); |
||||||
|
ps.setBigDecimal(6, info.getPayMoney()); |
||||||
|
//
|
||||||
|
ps.setString(7, info.getOutTradeNo()); |
||||||
|
ps.setString(8, info.getNoticeOrderNo()); |
||||||
|
ps.setString(9, info.getTreatNum()); |
||||||
|
}) > 0; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 判断体检订单是否已缴费 |
||||||
|
* |
||||||
|
* @param noticeOrderNo 体检订单号 |
||||||
|
*/ |
||||||
|
public boolean hasPaidByNoticeOrderNo(String noticeOrderNo) { |
||||||
|
String sql = "select * from peis_reserve where noticeOrderNo=? and payStatus=0"; |
||||||
|
return !DataBase.select(sql, PEISReserve.class, ps -> { |
||||||
|
ps.setString(1, noticeOrderNo); |
||||||
|
}).isEmpty(); |
||||||
|
} |
||||||
|
|
||||||
|
public PEISReserve selectByOutTradeNo(String outTradeNo) { |
||||||
|
String sql = "select * from peis_reserve where outTradeNo=?"; |
||||||
|
List<PEISReserve> list = DataBase.select(sql, PEISReserve.class, ps -> { |
||||||
|
ps.setString(1, outTradeNo); |
||||||
|
}); |
||||||
|
if (!list.isEmpty()) { |
||||||
|
return list.get(0); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public PEISReserve selectByNoticeOrderNo(String noticeOrderNo) { |
||||||
|
String sql = "select * from peis_reserve where noticeOrderNo=? and noticeStatus = 0 and payStatus=0"; |
||||||
|
List<PEISReserve> list = DataBase.select(sql, PEISReserve.class, ps -> { |
||||||
|
ps.setString(1, noticeOrderNo); |
||||||
|
}); |
||||||
|
if (!list.isEmpty()) { |
||||||
|
return list.get(0); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 修改退款状态 |
||||||
|
* |
||||||
|
* @param outTradeNo 订单号 |
||||||
|
* @param noticeOrderNo 体检订单号 |
||||||
|
* @param refundResult 退款描述 |
||||||
|
* @return 是否成功 |
||||||
|
*/ |
||||||
|
public boolean updateRefundResult(String outTradeNo, String noticeOrderNo, String refundResult, Integer refundStatus) { |
||||||
|
String sql = "update peis_reserve set refundTime=now(), refundResult=?, refundStatus=? where outTradeNo=? and noticeOrderNo=?"; |
||||||
|
return DataBase.update(sql, ps -> { |
||||||
|
ps.setString(1, refundResult); |
||||||
|
ps.setInt(2, refundStatus); |
||||||
|
ps.setString(3, outTradeNo); |
||||||
|
ps.setString(4, noticeOrderNo); |
||||||
|
}) > 0; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 修改支付状态 |
||||||
|
* |
||||||
|
* @param outTradeNo |
||||||
|
* @param bankTransNo |
||||||
|
* @param tradeNo |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public boolean updateMerPaidByOutTradeNo(String outTradeNo, String bankTransNo, String tradeNo) { |
||||||
|
String sql = "update peis_reserve set payStatusTime=now(), payStatus=0, bankTransNo=?, tradeNo=? where outTradeNo=? and bankTransNo is null"; |
||||||
|
return DataBase.update(sql, ps -> { |
||||||
|
ps.setString(1, bankTransNo); |
||||||
|
ps.setString(2, tradeNo); |
||||||
|
ps.setString(3, outTradeNo); |
||||||
|
}) > 0; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean updateNoticeStatusOK(String outTradeNo, String bankTransNo) { |
||||||
|
String sql = "update peis_reserve set noticeStatus=0, bankTransNo=? where outTradeNo=?"; |
||||||
|
return DataBase.update(sql, ps -> { |
||||||
|
ps.setString(1, bankTransNo); |
||||||
|
ps.setString(2, outTradeNo); |
||||||
|
}) > 0; |
||||||
|
} |
||||||
|
} |
||||||
@ -1,116 +0,0 @@ |
|||||||
package com.ynxbd.common.dao.peis; |
|
||||||
|
|
||||||
import com.ynxbd.common.bean.pay.PayCasebook; |
|
||||||
import com.ynxbd.common.bean.pay.Recipe; |
|
||||||
import com.ynxbd.common.bean.record.Record; |
|
||||||
import com.ynxbd.common.config.db.DataBase; |
|
||||||
|
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* @author 李进才 |
|
||||||
* @ClassName PeisDao |
|
||||||
* @Description TODO |
|
||||||
* @date 2023/11/16 15:43:00 |
|
||||||
*/ |
|
||||||
public class PeisDao { |
|
||||||
/** |
|
||||||
* 处方支付,数据预存(单个) |
|
||||||
* |
|
||||||
* @param recipe 支付信息 |
|
||||||
* @return 是否存储成功 |
|
||||||
*/ |
|
||||||
public boolean insert(Recipe recipe) { |
|
||||||
String sql = "insert into peis_reserve(updateTime, peisStatus, payStatus, openId, patientId, payMoney, totalFee, outTradeNo, recipeId, treatNum) values (now(),?,?,?,?,?,?,?,?,?)"; |
|
||||||
return DataBase.insert(sql, ps -> { |
|
||||||
ps.setInt(1, recipe.getPeisStatus()); |
|
||||||
ps.setInt(2, recipe.getPayStatus()); |
|
||||||
ps.setString(3, recipe.getOpenid()); |
|
||||||
ps.setString(4, recipe.getPatientId()); |
|
||||||
ps.setBigDecimal(5, recipe.getTotalFee()); |
|
||||||
ps.setBigDecimal(6,recipe.getPayMoney()); |
|
||||||
//
|
|
||||||
ps.setString(7, recipe.getOutTradeNo()); |
|
||||||
ps.setString(8, recipe.getRecipeId()); |
|
||||||
ps.setString(9, recipe.getTreatNum()); |
|
||||||
|
|
||||||
}) > 0; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 判断该处方是否重复计费 |
|
||||||
* @param recipeId 处方号 |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public boolean isRepeat(String recipeId){ |
|
||||||
String sql = "select * from peis_reserve where recipeId = ? and peisStatus = 0"; |
|
||||||
return !DataBase.select(sql,Recipe.class,ps->{ |
|
||||||
ps.setString(1,recipeId); |
|
||||||
}).isEmpty(); |
|
||||||
} |
|
||||||
|
|
||||||
public Recipe selectByOutTradeNo(String outTradeNo) { |
|
||||||
String sql = "select * from peis_reserve where outTradeNo=? order by updateTime desc"; |
|
||||||
List<Recipe> list = DataBase.select(sql, Recipe.class, ps -> { |
|
||||||
ps.setString(1, outTradeNo); |
|
||||||
}); |
|
||||||
if (list.size() > 0) { |
|
||||||
return list.get(0); |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean checkRefund(String outTradeNo){ |
|
||||||
String sql = "select * from peis_reserve where outTradeNo=? and refundResult = 'OK'"; |
|
||||||
return !DataBase.select(sql,Recipe.class,ps->{ |
|
||||||
ps.setString(1,outTradeNo); |
|
||||||
}).isEmpty(); |
|
||||||
} |
|
||||||
|
|
||||||
public Recipe selectByRecipeId(String recipeId) { |
|
||||||
String sql = "select * from peis_reserve where recipeId=? and peisStatus = 0 and payStatus=0 order by updateTime desc"; |
|
||||||
List<Recipe> list = DataBase.select(sql, Recipe.class, ps -> { |
|
||||||
ps.setString(1, recipeId); |
|
||||||
}); |
|
||||||
if (list.size() > 0) { |
|
||||||
return list.get(0); |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 修改退款描述 |
|
||||||
* |
|
||||||
* @param outTradeNo 订单号 |
|
||||||
* @param recipeId 体检订单号 |
|
||||||
* @param refundMsg 退款描述 |
|
||||||
* @return 是否成功 |
|
||||||
*/ |
|
||||||
public boolean updateRefundResult(String outTradeNo, String recipeId, String refundMsg) { |
|
||||||
// 退款成功
|
|
||||||
String sql = "update peis_reserve set refundResult=?, refundTime=now() where recipeId=? and outTradeNo=?"; |
|
||||||
return DataBase.update(sql, ps -> { |
|
||||||
ps.setString(1, refundMsg); |
|
||||||
ps.setString(2, recipeId); |
|
||||||
ps.setString(3, outTradeNo); |
|
||||||
}) > 0; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean updatePayStateOk(String outTradeNo, String bankTransNo,String tradeNo) { |
|
||||||
String sql = "update peis_reserve set payStatus=0, bankTransNo=?, TradeNo=? where outTradeNo=? and bankTransNo is null"; |
|
||||||
return DataBase.update(sql, ps -> { |
|
||||||
ps.setString(1, bankTransNo); |
|
||||||
ps.setString(2, tradeNo); |
|
||||||
ps.setString(3, outTradeNo); |
|
||||||
}) > 0; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean updatePeisStateOk(String outTradeNo, String bankTransNo) { |
|
||||||
String sql = "update peis_reserve set peisStatus=0, bankTransNo=? where outTradeNo=?"; |
|
||||||
return DataBase.update(sql, ps -> { |
|
||||||
ps.setString(1, bankTransNo); |
|
||||||
ps.setString(2, outTradeNo); |
|
||||||
}) > 0; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -0,0 +1,282 @@ |
|||||||
|
package com.ynxbd.common.service; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray; |
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.ynxbd.common.action.pay.PEnum; |
||||||
|
import com.ynxbd.common.bean.enums.MerchantEnum; |
||||||
|
import com.ynxbd.common.bean.pay.Order; |
||||||
|
import com.ynxbd.common.bean.pay.PEISOrderInfo; |
||||||
|
import com.ynxbd.common.bean.pay.PEISReserve; |
||||||
|
import com.ynxbd.common.dao.peis.PEISDao; |
||||||
|
import com.ynxbd.common.helper.common.JsonHelper; |
||||||
|
import com.ynxbd.common.helper.http.OkHttpHelper; |
||||||
|
import com.ynxbd.common.helper.xbd.XBDHelper; |
||||||
|
import com.ynxbd.common.result.*; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import okhttp3.FormBody; |
||||||
|
import okhttp3.RequestBody; |
||||||
|
import org.apache.commons.lang3.ObjectUtils; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author 王绍全 |
||||||
|
* @ClassName PEISService |
||||||
|
* @Description TODO |
||||||
|
* @date 2025/12/17 15:53:00 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Slf4j |
||||||
|
public class PEISService { |
||||||
|
public JsonResult get(String url, OkHttpHelper.MapParams params) { |
||||||
|
return OkHttpHelper.get(url, params, JsonResultEnum.SYS_PEIS_RESERVE); |
||||||
|
} |
||||||
|
|
||||||
|
public JsonResult postJson(String url, OkHttpHelper.MapParams params, OkHttpHelper.Header header) { |
||||||
|
return OkHttpHelper.postJson(url, params, header, JsonResultEnum.SYS_PEIS_RESERVE); |
||||||
|
} |
||||||
|
|
||||||
|
public JsonResult postForm(String url, OkHttpHelper.MapParams params, OkHttpHelper.Header header) { |
||||||
|
return OkHttpHelper.postForm(url, params, header, JsonResultEnum.SYS_PEIS_RESERVE); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 判断体检订单是否已缴费 |
||||||
|
* |
||||||
|
* @param noticeOrderNo 体检订单号 |
||||||
|
*/ |
||||||
|
public boolean hasPaidByNoticeOrderNo(String noticeOrderNo) { |
||||||
|
return new PEISDao().hasPaidByNoticeOrderNo(noticeOrderNo); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 订单信息记录 |
||||||
|
* |
||||||
|
* @param openid openid |
||||||
|
* @param patientId 患者id |
||||||
|
* @param treatNum 体检号 |
||||||
|
* @param outTradeNo 商户订单号 |
||||||
|
* @param totalFee 金额 |
||||||
|
* @param noticeOrderNo 体检订单号 |
||||||
|
* @return bool |
||||||
|
*/ |
||||||
|
public boolean isSavePEISOrder(String openid, String patientId, String treatNum, String outTradeNo, String totalFee, String noticeOrderNo) { |
||||||
|
PEISReserve info = new PEISReserve(); |
||||||
|
info.setOpenid(openid); |
||||||
|
info.setPatientId(patientId); |
||||||
|
info.setTreatNum(treatNum); |
||||||
|
info.setOutTradeNo(outTradeNo); |
||||||
|
info.setNoticeOrderNo(noticeOrderNo); |
||||||
|
info.setTotalFee(new BigDecimal(totalFee)); |
||||||
|
info.setPayMoney(new BigDecimal(totalFee)); |
||||||
|
info.setPayStatus(-1); |
||||||
|
info.setNoticeStatus(-1); |
||||||
|
return new PEISDao().insert(info); |
||||||
|
} |
||||||
|
|
||||||
|
public PEISReserve queryByOutTradeNo(String outTradeNo) { |
||||||
|
return new PEISDao().selectByOutTradeNo(outTradeNo); |
||||||
|
} |
||||||
|
|
||||||
|
public void payNotify(MerchantEnum merchantEnum, String openid, BigDecimal totalFee, String outTradeNo, String bankTransNo, String payDate, String payTime, String payInfo) { |
||||||
|
PEISDao peisDao = new PEISDao(); |
||||||
|
PEISReserve order = peisDao.selectByOutTradeNo(outTradeNo); |
||||||
|
|
||||||
|
if (order.hasPayStatusPaid() && order.hasNoticeStatusPaid()) { |
||||||
|
log.info("{} [体检预约]订单已支付,停止向下执行 outTradeNo={}, bankTransNo={}", merchantEnum.NAME, outTradeNo, bankTransNo); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
String tradeNo = PEnum.getTradeNo(bankTransNo, PEnum.PEIS_RESERVE); |
||||||
|
String noticeOrderNo = order.getNoticeOrderNo(); |
||||||
|
if (ObjectUtils.isEmpty(noticeOrderNo)) { |
||||||
|
log.info("{} [体检预约]存储的体检订单号为空 outTradeNo={}, bankTransNo={}", merchantEnum.NAME, outTradeNo, bankTransNo); |
||||||
|
return; |
||||||
|
} |
||||||
|
// 更新商户支付状态
|
||||||
|
if (!peisDao.updateMerPaidByOutTradeNo(outTradeNo, bankTransNo, tradeNo)) { |
||||||
|
log.info("{} [体检预约]更新订单失败,停止向下执行 outTradeNo={}, bankTransNo={}, tradeNo={}", merchantEnum.NAME, outTradeNo, bankTransNo, tradeNo); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if (order.hasNoticeStatusPaid()) { |
||||||
|
log.info("[体检预约]订单已支付 outTradeNo={}, bankTransNo={}, noticeOrderNo={}", outTradeNo, bankTransNo, noticeOrderNo); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
JsonResult jsonResult = postForm(XBDHelper.XBD_PEIS + "/wxUse/wxPay", params -> { |
||||||
|
params.put("orderNo", noticeOrderNo); |
||||||
|
params.put("payStatus", "OK"); |
||||||
|
params.put("payFailReason", ""); |
||||||
|
params.put("bankTransNo", bankTransNo); |
||||||
|
params.put("outTradeNo", outTradeNo); |
||||||
|
}, null); |
||||||
|
|
||||||
|
log.info("[体检预约]回调接口调用 {}", JsonHelper.toJsonString(jsonResult)); |
||||||
|
if (jsonResult.isTimeout()) { // 调用接口超时
|
||||||
|
log.info("[体检预约]回调接口调用超时 不进行退费处理"); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if (!jsonResult.success()) { // 通知失败
|
||||||
|
String message = jsonResult.getMessage(); |
||||||
|
if (message == null) { |
||||||
|
message = ""; |
||||||
|
} |
||||||
|
String refundDesc = "体检订单号:" + noticeOrderNo + " 通知体检系统异常:" + message; |
||||||
|
refundPEIS(merchantEnum, noticeOrderNo, outTradeNo, totalFee, refundDesc, new Date(), openid); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if (!peisDao.updateNoticeStatusOK(outTradeNo, bankTransNo)) { |
||||||
|
log.info("[体检预约]修改体检系统支付状态失败 outTradeNo={}, bankTransNo={}", outTradeNo, bankTransNo); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据体检订单号查询体检接口 |
||||||
|
* |
||||||
|
* @param noticeOrderNo 体检订单号 |
||||||
|
* @return bean |
||||||
|
*/ |
||||||
|
public PEISOrderInfo queryPEISOrderByNoticeOrderNo(String noticeOrderNo) throws ServiceException { |
||||||
|
JsonResult jsonResult = get(XBDHelper.XBD_PEIS + "/wxUse/GetOrder", params -> { |
||||||
|
params.put("orderNo", noticeOrderNo); |
||||||
|
}); |
||||||
|
log.info("[体检预约]订单查询 {}", JsonHelper.toJsonString(jsonResult)); |
||||||
|
if (!jsonResult.success()) { |
||||||
|
String message = jsonResult.getMessage(); |
||||||
|
log.info("[体检预约]订单查询失败:{}", message); |
||||||
|
throw new ServiceException(message); |
||||||
|
} |
||||||
|
return jsonResult.dataMapGetNodeToBean(PEISOrderInfo.class); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 体检退费接口 |
||||||
|
* |
||||||
|
* @param noticeOrderNo 订单号 |
||||||
|
* @param merchantEnum 支付方式 |
||||||
|
* @param outTradeNo outTradeNo |
||||||
|
* @param totalFee 总金额 |
||||||
|
* @param refundDesc 退费描述 |
||||||
|
* @param tradeDate 退费时间 |
||||||
|
* @param openid openid |
||||||
|
*/ |
||||||
|
public Result refundPEIS(MerchantEnum merchantEnum, String noticeOrderNo, String outTradeNo, BigDecimal totalFee, String refundDesc, Date tradeDate, String openid) { |
||||||
|
try { |
||||||
|
if (totalFee.compareTo(BigDecimal.ZERO) == 0) { |
||||||
|
log.info("{} [体检预约]订单金额为0无需退费 outTradeNo={}, noticeOrderNo={}, totalFee={}", merchantEnum.NAME, outTradeNo, noticeOrderNo, totalFee); |
||||||
|
return Result.error("订单金额为0无需退费"); |
||||||
|
} |
||||||
|
|
||||||
|
PEISDao peisDao = new PEISDao(); |
||||||
|
PEISReserve dbOrder = peisDao.selectByOutTradeNo(outTradeNo); |
||||||
|
if (dbOrder.hasRefundByRefundResult()) { |
||||||
|
log.info("{} [体检预约]订单已退费 outTradeNo={}, noticeOrderNo={}, totalFee={}", merchantEnum.NAME, outTradeNo, noticeOrderNo, totalFee); |
||||||
|
return Result.error("订单已退费,请勿重复取消"); |
||||||
|
} |
||||||
|
|
||||||
|
PEISOrderInfo findOrder = queryPEISOrderByNoticeOrderNo(noticeOrderNo); |
||||||
|
log.info("[体检预约] findOrder={}", JsonHelper.toJsonString(findOrder)); |
||||||
|
if (findOrder == null) { |
||||||
|
log.info("[体检预约]未查询到订单 noticeOrderNo={}", noticeOrderNo); |
||||||
|
return Result.error("[体检预约]未查询到订单"); |
||||||
|
} |
||||||
|
BigDecimal fee = findOrder.getFee(); |
||||||
|
BigDecimal payMoney = dbOrder.getPayMoney(); |
||||||
|
if (totalFee.compareTo(payMoney) != 0 || fee.compareTo(payMoney) != 0) { |
||||||
|
log.info("{} [体检预约]订单金额不匹配 outTradeNo={}, noticeOrderNo={}, totalFee={}, payMoney={}, fee={}", merchantEnum.NAME, outTradeNo, noticeOrderNo, totalFee, payMoney, fee); |
||||||
|
return Result.error(ResultEnum.REFUND_MONEY_ERROR); |
||||||
|
} |
||||||
|
|
||||||
|
Boolean isHisCost = findOrder.getIsCost(); |
||||||
|
if (isHisCost != null && isHisCost) { |
||||||
|
log.info("{} [体检预约]HIS已计费,禁止退费 outTradeNo={}, noticeOrderNo={}, totalFee={}", merchantEnum.NAME, outTradeNo, noticeOrderNo, totalFee); |
||||||
|
return Result.error("退费错误,体检系统his显示已计费,不允许退费"); |
||||||
|
} |
||||||
|
|
||||||
|
String refundResult = "OK"; |
||||||
|
Order orderRefund = PayService.refund(merchantEnum, outTradeNo, noticeOrderNo, totalFee, totalFee, refundDesc, tradeDate, openid, null, refundDesc); |
||||||
|
if (!orderRefund.isSuccess()) { |
||||||
|
refundResult = orderRefund.getRefundResult(); |
||||||
|
log.info("{} [体检预约]退费失败 outTradeNo={}, totalFee={}, noticeOrderNo={}, refundResult={}", merchantEnum.NAME, outTradeNo, totalFee, noticeOrderNo, refundResult); |
||||||
|
} |
||||||
|
|
||||||
|
Integer refundStatus = "OK".equals(refundResult) ? 1 : -1; |
||||||
|
boolean isUpdate = peisDao.updateRefundResult(outTradeNo, noticeOrderNo, refundResult, refundStatus); |
||||||
|
if (!isUpdate) { |
||||||
|
log.info("{} [体检预约][退费错误]退费信息更新失败 noticeOrderNo={}", merchantEnum.NAME, noticeOrderNo); |
||||||
|
} |
||||||
|
if (orderRefund.isSuccess()) { // 退费成功
|
||||||
|
return Result.success(); |
||||||
|
} |
||||||
|
return Result.error(refundResult); |
||||||
|
} catch (Exception e) { |
||||||
|
return Result.error(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 取消预约 |
||||||
|
* |
||||||
|
* @param noticeOrderNo 体检订单号 |
||||||
|
* @param refundStatus 退费状态 |
||||||
|
* @param refundFailReason 退费描述 |
||||||
|
* @return bool |
||||||
|
*/ |
||||||
|
public boolean cancelPEISReserve(String noticeOrderNo, String refundStatus, String refundFailReason) throws ServiceException { |
||||||
|
JsonResult jsonResult = postForm(XBDHelper.XBD_PEIS + "/wxUse/wxRefund", params -> { |
||||||
|
params.put("orderNo", noticeOrderNo); |
||||||
|
params.put("refundStatus", refundStatus); // 退费状态(成功:OK,失败:FAIL)
|
||||||
|
params.put("refundFailReason", refundFailReason); |
||||||
|
}, null); |
||||||
|
log.info("[体检预约]取消预约 {}", JsonHelper.toJsonString(jsonResult)); |
||||||
|
if (!jsonResult.success()) { |
||||||
|
String message = jsonResult.getMessage(); |
||||||
|
log.info("[体检预约]取消预约失败 noticeOrderNo={}, message={}", noticeOrderNo, message); |
||||||
|
throw new ServiceException(message); |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
public JSONArray queryPEISRecordByCardNo(String cardNo, String begDate, String endDate) throws ServiceException { |
||||||
|
RequestBody formBody = new FormBody.Builder(). |
||||||
|
add("enIdCard", cardNo) |
||||||
|
.add("begDate", begDate) |
||||||
|
.add("endDate", endDate) |
||||||
|
.build(); |
||||||
|
String result = OkHttpHelper.post(XBDHelper.XBD_PEIS + "/WxUse/GetPeisOfPacsResult", formBody); |
||||||
|
if (ObjectUtils.isEmpty(result)) { |
||||||
|
throw new ServiceException("请求失败"); |
||||||
|
} |
||||||
|
JSONObject jsonResult = JsonHelper.parseObject(result); |
||||||
|
if (jsonResult == null) { |
||||||
|
throw new ServiceException("请求失败"); |
||||||
|
} |
||||||
|
String code = jsonResult.getString("code"); |
||||||
|
if (!"200".equals(code)) { |
||||||
|
String message = jsonResult.getString("message"); |
||||||
|
throw new ServiceException(ObjectUtils.isEmpty(message) ? "请求失败" : message); |
||||||
|
} |
||||||
|
return jsonResult.getJSONArray("data"); |
||||||
|
} |
||||||
|
|
||||||
|
// public static void main(String[] args) {
|
||||||
|
// RequestBody formBody = new FormBody.Builder().
|
||||||
|
// add("orderNo", "Fee2023112900000001")
|
||||||
|
// .add("payStatus", "OK")
|
||||||
|
// .add("payFailReason", "")
|
||||||
|
// .add("bankTransNo", "4200001809202305012522296970")
|
||||||
|
// .build();
|
||||||
|
// String result = OkHttpHelper.post(XBDHelper.XBD_PEIS + "/wxUse/wxPay", formBody);
|
||||||
|
// System.out.println(result);
|
||||||
|
//// String result = OkHttpHelper.get(XBDHelper.XBD_PEIS+"/wxUse/GetOrder",params -> {
|
||||||
|
//// params.put("orderNo","Fee2023112900000001");
|
||||||
|
//// });
|
||||||
|
//// JSONObject jsonResult = JsonHelper.parseObject(result);
|
||||||
|
//// System.out.println(result);
|
||||||
|
// }
|
||||||
|
|
||||||
|
} |
||||||
@ -1,221 +0,0 @@ |
|||||||
package com.ynxbd.common.service; |
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON; |
|
||||||
import com.alibaba.fastjson.JSONArray; |
|
||||||
import com.alibaba.fastjson.JSONObject; |
|
||||||
import com.ynxbd.common.action.pay.PEnum; |
|
||||||
import com.ynxbd.common.bean.enums.MerchantEnum; |
|
||||||
import com.ynxbd.common.bean.pay.Order; |
|
||||||
import com.ynxbd.common.bean.pay.Recipe; |
|
||||||
import com.ynxbd.common.dao.peis.PeisDao; |
|
||||||
import com.ynxbd.common.helper.common.JsonHelper; |
|
||||||
import com.ynxbd.common.helper.his.HisHelper; |
|
||||||
import com.ynxbd.common.helper.http.OkHttpHelper; |
|
||||||
import com.ynxbd.common.helper.xbd.HttpHelper; |
|
||||||
import com.ynxbd.common.helper.xbd.XBDHelper; |
|
||||||
import com.ynxbd.common.result.JsonResult; |
|
||||||
import com.ynxbd.common.result.JsonResultEnum; |
|
||||||
import com.ynxbd.common.result.Result; |
|
||||||
import com.ynxbd.common.result.ServiceException; |
|
||||||
import lombok.extern.slf4j.Slf4j; |
|
||||||
import okhttp3.FormBody; |
|
||||||
import okhttp3.RequestBody; |
|
||||||
import org.apache.commons.lang3.ObjectUtils; |
|
||||||
|
|
||||||
import java.math.BigDecimal; |
|
||||||
import java.util.Date; |
|
||||||
import java.util.HashMap; |
|
||||||
import java.util.Map; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author 李进才 |
|
||||||
* @ClassName PeisService |
|
||||||
* @Description TODO |
|
||||||
* @date 2023/11/16 15:53:00 |
|
||||||
*/ |
|
||||||
|
|
||||||
@Slf4j |
|
||||||
public class PeisService { |
|
||||||
|
|
||||||
public Boolean Reserve(String openid, String patientId, String treatNum, String outTradeNo, String totalFee, String recipeId) { |
|
||||||
Recipe recipe = new Recipe(); |
|
||||||
recipe.setOpenid(openid); |
|
||||||
recipe.setPatientId(patientId); |
|
||||||
recipe.setTreatNum(treatNum); |
|
||||||
recipe.setOutTradeNo(outTradeNo); |
|
||||||
recipe.setRecipeId(recipeId); |
|
||||||
recipe.setTotalFee(new BigDecimal(totalFee)); |
|
||||||
recipe.setPayMoney(new BigDecimal(totalFee)); |
|
||||||
recipe.setPeisStatus(-1); |
|
||||||
recipe.setPayStatus(-1); |
|
||||||
if (new PeisDao().isRepeat(recipe.getRecipeId())) { |
|
||||||
log.info("[体检预约]该处方号已经缴费,recipeId-{}", recipe.getRecipeId()); |
|
||||||
return false; |
|
||||||
} |
|
||||||
return new PeisDao().insert(recipe); |
|
||||||
} |
|
||||||
|
|
||||||
public void payNotify(MerchantEnum merchantEnum, String openid, BigDecimal totalFee, String outTradeNo, String bankTransNo, String payInfo, Date tradeDate) { |
|
||||||
PeisDao peisDao = new PeisDao(); |
|
||||||
Recipe recipe = peisDao.selectByOutTradeNo(outTradeNo); |
|
||||||
String tradeNo = HisHelper.getHisTradeNo(bankTransNo, PEnum.PEIS_RESERVE); |
|
||||||
String recipeId = recipe.getRecipeId(); |
|
||||||
Integer payStates = recipe.getPayStatus(); |
|
||||||
if (payStates == 0) { |
|
||||||
log.error("[体检预约] 拒绝支付-订单已支付 outTradeNo={}, bankTransNo={}, recipeId={}", outTradeNo, bankTransNo, recipeId); |
|
||||||
return; |
|
||||||
} |
|
||||||
if (!peisDao.updatePayStateOk(outTradeNo, bankTransNo, tradeNo)) { |
|
||||||
log.info("[体检预约]修改支付状态失败 outTradeNo={}, bankTransNo={},tradeNo-{}", outTradeNo, bankTransNo, tradeNo); |
|
||||||
RequestBody formBody = new FormBody.Builder(). |
|
||||||
add("orderNo", recipeId) |
|
||||||
.add("payStatus", "FAIL") |
|
||||||
.add("payFailReason", "修改支付状态失败") |
|
||||||
.add("bankTransNo", bankTransNo) |
|
||||||
.add("outTradeNo", outTradeNo) |
|
||||||
.build(); |
|
||||||
String result = OkHttpHelper.post(XBDHelper.XBD_PEIS + "/wxUse/wxPay", formBody); |
|
||||||
JSONObject jsonResult = JsonHelper.parseObject(result); |
|
||||||
log.info("[体检预约]缴费失败回调体检系统计费 recipeId={}, bankTransNo-{}, 计费状态-{}, 计费信息-{}", recipeId, bankTransNo, jsonResult.get("code"), jsonResult.get("message")); |
|
||||||
String pushMessage = "体检预约失败已申请退款,原因:修改支付状态失败,订单号:" + outTradeNo + "orderNo:" + recipeId; |
|
||||||
; |
|
||||||
peisAutoRefund(recipeId, merchantEnum, outTradeNo, totalFee, pushMessage, tradeDate, openid); |
|
||||||
} else { |
|
||||||
RequestBody formBody = new FormBody.Builder(). |
|
||||||
add("orderNo", recipeId) |
|
||||||
.add("payStatus", "OK") |
|
||||||
.add("payFailReason", "") |
|
||||||
.add("bankTransNo", bankTransNo) |
|
||||||
.add("outTradeNo", outTradeNo) |
|
||||||
.build(); |
|
||||||
String result = OkHttpHelper.post(XBDHelper.XBD_PEIS + "/wxUse/wxPay", formBody); |
|
||||||
if (result == null) { |
|
||||||
log.info("[体检预约]体检服务无响应,开始退费"); |
|
||||||
String pushMessage = "体检预约失败已申请退款,原因:体检服务无响应,订单号:" + outTradeNo + "orderNo:" + recipeId; |
|
||||||
peisAutoRefund(recipeId, merchantEnum, outTradeNo, totalFee, pushMessage, tradeDate, openid); |
|
||||||
} |
|
||||||
JSONObject jsonResult = JsonHelper.parseObject(result); |
|
||||||
log.info("[体检预约]缴费成功回调体检系统计费 recipeId={}, bankTransNo-{}, 计费状态-{}, 计费信息-{}", recipeId, bankTransNo, jsonResult.get("code"), jsonResult.get("message")); |
|
||||||
if ("200".equals(jsonResult.get("code").toString())) { |
|
||||||
if (!peisDao.updatePeisStateOk(outTradeNo, bankTransNo)) { |
|
||||||
log.info("[体检预约]修改体检系统支付状态失败 outTradeNo={}, bankTransNo={}", outTradeNo, bankTransNo); |
|
||||||
} |
|
||||||
} else { |
|
||||||
log.info("[体检预约]回调体检系统计费状态码异常 recipeId={}, bankTransNo-{}, 计费状态-{}, 计费信息-{}", recipeId, bankTransNo, jsonResult.get("code"), jsonResult.get("message")); |
|
||||||
String pushMessage = "体检预约失败已申请退款,原因:体检系统计费失败,订单号:" + outTradeNo + "orderNo:" + recipeId; |
|
||||||
peisAutoRefund(recipeId, merchantEnum, outTradeNo, totalFee, pushMessage, tradeDate, openid); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 体检退费接口 |
|
||||||
* |
|
||||||
* @param recipeId 订单号 |
|
||||||
* @param merchantEnum 支付方式 |
|
||||||
* @param outTradeNo outTradeNo |
|
||||||
* @param totalFee 总金额 |
|
||||||
* @param pushInfo 提示信息 |
|
||||||
* @param tradeDate 退费时间 |
|
||||||
* @param openid openid |
|
||||||
*/ |
|
||||||
public Result peisAutoRefund(String recipeId, MerchantEnum merchantEnum, String outTradeNo, BigDecimal totalFee, String pushInfo, Date tradeDate, String openid) { |
|
||||||
PeisDao peisDao = new PeisDao(); |
|
||||||
if (peisDao.checkRefund(outTradeNo)) { |
|
||||||
log.info("{} [体检预约][该订单已经退费,请不要重复退费] outTradeNo={}, recipeId={}, totalFee={}", merchantEnum.NAME, outTradeNo, recipeId, totalFee); |
|
||||||
return Result.error("该订单已经退费,请不要重复退费"); |
|
||||||
} |
|
||||||
String result = OkHttpHelper.get(XBDHelper.XBD_PEIS + "/wxUse/GetOrder", params -> { |
|
||||||
params.put("orderNo", recipeId); |
|
||||||
}); |
|
||||||
if (result == null) { |
|
||||||
log.info("{} [体检预约][退费错误,计费信息查询失败] outTradeNo={}, recipeId={}, totalFee={}", merchantEnum.NAME, outTradeNo, recipeId, totalFee); |
|
||||||
return Result.error("退费错误,计费信息查询失败"); |
|
||||||
} |
|
||||||
JSONObject jsonResult = JsonHelper.parseObject(result); |
|
||||||
String fee = jsonResult.getJSONObject("data").get("fee").toString(); |
|
||||||
boolean isWxPay = Boolean.parseBoolean(jsonResult.getJSONObject("data").get("isWxPay").toString()); |
|
||||||
boolean isCost = Boolean.parseBoolean(jsonResult.getJSONObject("data").get("isCost").toString()); |
|
||||||
if (totalFee.compareTo(BigDecimal.ZERO) == 0 || "0".equals(fee)) { |
|
||||||
log.info("{} [体检预约][退费错误,退费金额为0] outTradeNo={}, recipeId={}, totalFee={}", merchantEnum.NAME, outTradeNo, recipeId, totalFee); |
|
||||||
return Result.error("退费错误,退费金额为0"); |
|
||||||
} |
|
||||||
if (totalFee.compareTo(new BigDecimal(fee)) != 0) { |
|
||||||
log.info("{} [体检预约][退费错误,退费金额跟订单金额不符] outTradeNo={}, recipeId={}, totalFee={}", merchantEnum.NAME, outTradeNo, recipeId, totalFee); |
|
||||||
return Result.error("退费错误,退费金额跟订单金额不符"); |
|
||||||
} |
|
||||||
// if(isWxPay){
|
|
||||||
// log.info("{} [体检预约][退费错误,体检显示已计费,不允许退费] recipeId-{}, outTradeNo={}, recipeId={}, totalFee={}", recipeId, merchantEnum.NAME, outTradeNo, recipeId, totalFee);
|
|
||||||
// return Result.error("退费错误,体检显示已计费,不允许退费");
|
|
||||||
// }
|
|
||||||
if (isCost) { |
|
||||||
log.info("{} [体检预约][退费错误,his显示已计费,不允许退费] outTradeNo={}, recipeId={}, totalFee={}", merchantEnum.NAME, outTradeNo, recipeId, totalFee); |
|
||||||
return Result.error("退费错误,体检系统his显示已计费,不允许退费"); |
|
||||||
} |
|
||||||
String refundResult; |
|
||||||
Order orderRefund = PayService.refund(merchantEnum, outTradeNo, recipeId, totalFee, totalFee, pushInfo, tradeDate, openid, null, pushInfo); |
|
||||||
if (!orderRefund.isSuccess()) { |
|
||||||
log.info("{} [体检预约][退费错误] outTradeNo={}, totalFee={},recipeId-{}", merchantEnum.NAME, outTradeNo, totalFee, recipeId); |
|
||||||
refundResult = orderRefund.getRefundResult(); |
|
||||||
} else { |
|
||||||
refundResult = "OK"; |
|
||||||
} |
|
||||||
boolean isUpdate = peisDao.updateRefundResult(outTradeNo, recipeId, refundResult); |
|
||||||
if (!isUpdate) { |
|
||||||
log.info("{} [体检预约][退费错误]退费信息更新失败 recipeId={}", merchantEnum.NAME, recipeId); |
|
||||||
} |
|
||||||
return Result.success(); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public boolean peisRefund(String recipeId, String refundStatus, String refundFailReason) { |
|
||||||
RequestBody formBody = new FormBody.Builder(). |
|
||||||
add("orderNo", recipeId) |
|
||||||
.add("refundStatus", refundStatus) |
|
||||||
.add("refundFailReason", refundFailReason) |
|
||||||
.build(); |
|
||||||
String result = OkHttpHelper.post(XBDHelper.XBD_PEIS + "/wxUse/wxRefund", formBody); |
|
||||||
JSONObject jsonResult = JsonHelper.parseObject(result); |
|
||||||
return "200".equals(jsonResult.get("code")); |
|
||||||
} |
|
||||||
|
|
||||||
public JSONArray getPeisByCardNo(String cardNo, String begDate, String endDate) throws ServiceException { |
|
||||||
RequestBody formBody = new FormBody.Builder(). |
|
||||||
add("enIdCard", cardNo) |
|
||||||
.add("begDate", begDate) |
|
||||||
.add("endDate", endDate) |
|
||||||
.build(); |
|
||||||
String result = OkHttpHelper.post(XBDHelper.XBD_PEIS + "/WxUse/GetPeisOfPacsResult", formBody); |
|
||||||
if (ObjectUtils.isEmpty(result)) { |
|
||||||
throw new ServiceException("请求失败"); |
|
||||||
} |
|
||||||
JSONObject jsonResult = JsonHelper.parseObject(result); |
|
||||||
if (jsonResult == null) { |
|
||||||
throw new ServiceException("请求失败"); |
|
||||||
} |
|
||||||
String code = jsonResult.getString("code"); |
|
||||||
if (!"200".equals(code)) { |
|
||||||
String message = jsonResult.getString("message"); |
|
||||||
throw new ServiceException(ObjectUtils.isEmpty(message) ? "请求失败" : message); |
|
||||||
} |
|
||||||
return jsonResult.getJSONArray("data"); |
|
||||||
} |
|
||||||
|
|
||||||
public static void main(String[] args) { |
|
||||||
RequestBody formBody = new FormBody.Builder(). |
|
||||||
add("orderNo", "Fee2023112900000001") |
|
||||||
.add("payStatus", "OK") |
|
||||||
.add("payFailReason", "") |
|
||||||
.add("bankTransNo", "4200001809202305012522296970") |
|
||||||
.build(); |
|
||||||
String result = OkHttpHelper.post(XBDHelper.XBD_PEIS + "/wxUse/wxPay", formBody); |
|
||||||
System.out.println(result); |
|
||||||
// String result = OkHttpHelper.get(XBDHelper.XBD_PEIS+"/wxUse/GetOrder",params -> {
|
|
||||||
// params.put("orderNo","Fee2023112900000001");
|
|
||||||
// });
|
|
||||||
// JSONObject jsonResult = JsonHelper.parseObject(result);
|
|
||||||
// System.out.println(result);
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,15 +0,0 @@ |
|||||||
package com.ynxbd.common.service; |
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j; |
|
||||||
import org.apache.commons.codec.digest.DigestUtils; |
|
||||||
|
|
||||||
@Slf4j |
|
||||||
public class Test { |
|
||||||
|
|
||||||
public static void main(String[] args) { |
|
||||||
// System.out.println(JsonHelper.toJsonString(queryOrder("WX7c1ea238c08f420d2bb8262f7254")));
|
|
||||||
String piMd5 = "9444144" + "Z2007" + "xbd"; |
|
||||||
piMd5 = DigestUtils.md5Hex(piMd5).toUpperCase(); |
|
||||||
System.out.println(piMd5); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,33 +0,0 @@ |
|||||||
package com.ynxbd.wx.servlet.test; |
|
||||||
|
|
||||||
import com.ynxbd.wx.wxfactory.WxPayHelper; |
|
||||||
import com.ynxbd.common.result.Result; |
|
||||||
import com.ynxbd.wx.servlet.base.BaseServlet; |
|
||||||
|
|
||||||
import javax.servlet.annotation.WebServlet; |
|
||||||
import javax.servlet.http.HttpServletRequest; |
|
||||||
import javax.servlet.http.HttpServletResponse; |
|
||||||
import java.math.BigDecimal; |
|
||||||
|
|
||||||
/** |
|
||||||
* @Author wsq |
|
||||||
* @Date 2021/3/4 17:57 |
|
||||||
* @Copyright @ 2020 云南新八达科技有限公司 All rights reserved. |
|
||||||
*/ |
|
||||||
@WebServlet("/refundTest") |
|
||||||
public class RefundTestServlet extends BaseServlet { |
|
||||||
|
|
||||||
// show status like 'Threads%';
|
|
||||||
private int i = 0; |
|
||||||
|
|
||||||
@Override |
|
||||||
protected synchronized Result requestMapping(HttpServletRequest req, HttpServletResponse resp) throws Exception { |
|
||||||
if (i == 0) { |
|
||||||
i++; |
|
||||||
// 1
|
|
||||||
WxPayHelper.refund("", "", new BigDecimal("0.800"), new BigDecimal("0.800"), "手动退费"); |
|
||||||
// 2
|
|
||||||
} |
|
||||||
return Result.success(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,27 +0,0 @@ |
|||||||
//package com.ynxbd.wx.servlet;
|
|
||||||
//
|
|
||||||
//import com.ynxbd.common.result.Result;
|
|
||||||
//import com.ynxbd.wx.servlet.base.BaseServlet;
|
|
||||||
//import com.ynxbd.wx.wxfactory.WxAuthHelper;
|
|
||||||
//import lombok.extern.slf4j.Slf4j;
|
|
||||||
//
|
|
||||||
//import javax.servlet.annotation.WebServlet;
|
|
||||||
//import javax.servlet.http.HttpServletRequest;
|
|
||||||
//import javax.servlet.http.HttpServletResponse;
|
|
||||||
//import java.io.UnsupportedEncodingException;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 判读微信是否已经认证
|
|
||||||
// *
|
|
||||||
// * @author antgan
|
|
||||||
// */
|
|
||||||
//@Slf4j
|
|
||||||
//@WebServlet("/is_auth")
|
|
||||||
//public class WxIsAuthServlet extends BaseServlet {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected Result requestMapping(HttpServletRequest request, HttpServletResponse resp) throws Exception {
|
|
||||||
// return WxAuthHelper.isAuth(request);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
Loading…
Reference in new issue