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.
576 lines
22 KiB
576 lines
22 KiB
2 years ago
|
package com.ynxbd.common.dao;
|
||
|
|
||
|
import com.ynxbd.common.action.pay.PEnum;
|
||
|
import com.ynxbd.common.bean.pay.Order;
|
||
|
import com.ynxbd.common.bean.pay.PayResult;
|
||
|
import com.ynxbd.common.bean.pay.Recipe;
|
||
|
import com.ynxbd.common.config.db.DataBase;
|
||
|
import com.ynxbd.common.helper.his.HisHelper;
|
||
|
import lombok.extern.slf4j.Slf4j;
|
||
|
import org.apache.commons.lang3.ObjectUtils;
|
||
|
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.HashMap;
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
import java.util.stream.Collectors;
|
||
|
|
||
|
|
||
|
/**
|
||
|
* pay和payResult表操作
|
||
|
*
|
||
|
* @Author wsq
|
||
|
* @Date 2020/11/19 11:41
|
||
|
* @Copyright @ 2020 云南新八达科技有限公司 All rights reserved.
|
||
|
*/
|
||
|
@Slf4j
|
||
|
public class RecipeDao {
|
||
|
|
||
|
/**
|
||
|
* 查询是否已支付成功(his调用已成功)
|
||
|
*
|
||
|
* @param patientId 患者id
|
||
|
* @param treatNum 门诊号
|
||
|
* @param recipeId 处方号
|
||
|
* @return 是否已支付完成
|
||
|
*/
|
||
|
public boolean isHisPaidByPatient(String patientId, String treatNum, String recipeId) {
|
||
|
String sql = "select * from pay where patientId= ? and treatNum= ? and recipeId= ? and hisStatus=0";
|
||
|
return DataBase.select(sql, PayResult.class, ps -> {
|
||
|
ps.setString(1, patientId);
|
||
|
ps.setString(2, treatNum);
|
||
|
ps.setString(3, recipeId);
|
||
|
}).size() > 0;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 单张处方是否已经支付成功
|
||
|
*
|
||
|
* @param outTradeNo 订单号组
|
||
|
* @param recipeId 处方id
|
||
|
*/
|
||
|
public boolean isHisPaidByRecipeId(String outTradeNo, String recipeId) {
|
||
|
return selectSuccessByOutTradeNoAndRecipeId(outTradeNo, recipeId) != null;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 查询是否已经发起支付
|
||
|
*
|
||
|
* @param outTradeNo 微信订单号
|
||
|
* @return 是否已经发起支付
|
||
|
*/
|
||
|
public boolean isHisPaidByOutTradeNo(String outTradeNo) {
|
||
|
String sql = "select * from pay where outTradeNo=? and hisStatus=0";
|
||
|
return DataBase.select(sql, Recipe.class, ps -> {
|
||
|
ps.setString(1, outTradeNo);
|
||
|
}).size() > 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 处方支付,数据预存(单个)
|
||
|
*
|
||
|
* @param recipe 支付信息
|
||
|
* @return 是否存储成功
|
||
|
*/
|
||
|
public boolean insert(Recipe recipe) {
|
||
|
String sql = "insert into pay(updateTime, hisStatus, payStatus, openId, patientId, payWay, payMoney, totalFee, outTradeNo, bankTransNo, tradeNo, recipeId, treatNum, authCode, invoiceTransNo, hisTransNo, operateUser, deptCode, deptName, reqDeptCode, reqDeptName, hospitalArea, feeId, feeInfo) values (now(),?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?, ?,?,?)";
|
||
|
return DataBase.insert(sql, ps -> {
|
||
|
ps.setInt(1, recipe.getHisStatus());
|
||
|
ps.setInt(2, recipe.getPayStatus());
|
||
|
ps.setString(3, recipe.getOpenid());
|
||
|
ps.setString(4, recipe.getPatientId());
|
||
|
ps.setString(5, recipe.getPayWay());
|
||
|
ps.setBigDecimal(6, recipe.getPayMoney());
|
||
|
ps.setBigDecimal(7, recipe.getTotalFee());
|
||
|
//
|
||
|
ps.setString(8, recipe.getOutTradeNo());
|
||
|
ps.setString(9, recipe.getBankTransNo());
|
||
|
ps.setString(10, recipe.getTradeNo());
|
||
|
ps.setString(11, recipe.getRecipeId());
|
||
|
ps.setString(12, recipe.getTreatNum());
|
||
|
ps.setString(13, recipe.getAuthCode());
|
||
|
ps.setString(14, recipe.getInvoiceTransNo());
|
||
|
ps.setString(15, recipe.getHisTransNo());
|
||
|
ps.setString(16, recipe.getOperateUser());
|
||
|
|
||
|
ps.setString(17, recipe.getDeptCode());
|
||
|
ps.setString(18, recipe.getDeptName());
|
||
|
ps.setString(19, recipe.getReqDeptCode());
|
||
|
ps.setString(20, recipe.getReqDeptName());
|
||
|
ps.setString(21, recipe.getHospitalArea());
|
||
|
ps.setString(22, recipe.getFeeId());
|
||
|
ps.setString(23, recipe.getFeeInfo());
|
||
|
}) > 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 处方支付,数据预存(单个)
|
||
|
*
|
||
|
* @param recipe 支付信息
|
||
|
* @return 是否存储成功
|
||
|
*/
|
||
|
public boolean insertMedical(Recipe recipe) {
|
||
|
String sql = "insert into pay(updateTime, hisStatus, payStatus, openId, patientId, payWay, payMoney, totalFee, outTradeNo, bankTransNo, tradeNo, recipeId, treatNum, authCode, invoiceTransNo, hisTransNo, operateUser, deptCode, deptName, reqDeptCode, reqDeptName, hospitalArea, PayOrdId, AcctFee, HifpFee, ChrgBchno, MdTrtId, MdUserId, RecipeJson) values (now(),?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?)";
|
||
|
return DataBase.insert(sql, ps -> {
|
||
|
ps.setInt(1, recipe.getHisStatus());
|
||
|
ps.setInt(2, recipe.getPayStatus());
|
||
|
ps.setString(3, recipe.getOpenid());
|
||
|
ps.setString(4, recipe.getPatientId());
|
||
|
ps.setString(5, recipe.getPayWay());
|
||
|
ps.setBigDecimal(6, recipe.getPayMoney());
|
||
|
ps.setBigDecimal(7, recipe.getTotalFee());
|
||
|
//
|
||
|
|
||
|
ps.setString(8, recipe.getOutTradeNo());
|
||
|
ps.setString(9, recipe.getBankTransNo());
|
||
|
ps.setString(10, recipe.getTradeNo());
|
||
|
ps.setString(11, recipe.getRecipeId());
|
||
|
ps.setString(12, recipe.getTreatNum());
|
||
|
ps.setString(13, recipe.getAuthCode());
|
||
|
ps.setString(14, recipe.getInvoiceTransNo());
|
||
|
ps.setString(15, recipe.getHisTransNo());
|
||
|
ps.setString(16, recipe.getOperateUser());
|
||
|
|
||
|
ps.setString(17, recipe.getDeptCode());
|
||
|
ps.setString(18, recipe.getDeptName());
|
||
|
ps.setString(19, recipe.getReqDeptCode());
|
||
|
ps.setString(20, recipe.getReqDeptName());
|
||
|
ps.setString(21, recipe.getHospitalArea());
|
||
|
//
|
||
|
ps.setString(22, recipe.getPayOrdId());
|
||
|
ps.setBigDecimal(23, recipe.getAcctFee());
|
||
|
ps.setBigDecimal(24, recipe.getHifpFee());
|
||
|
ps.setString(25, recipe.getChrgBchno());
|
||
|
ps.setString(26, recipe.getMdTrtId());
|
||
|
ps.setString(27, recipe.getMdUserId());
|
||
|
ps.setString(28, recipe.getRecipeJson());
|
||
|
}) > 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 处方支付,数据预存(集合)
|
||
|
*
|
||
|
* @param recipeList 处方集
|
||
|
* @return 是否存储成功
|
||
|
*/
|
||
|
public int insertBatch(List<Recipe> recipeList) {
|
||
|
String sql = "insert into pay(updateTime, hisStatus, payStatus, openId, patientId, payWay, payMoney, totalFee, outTradeNo, bankTransNo, tradeNo, recipeId, treatNum, authCode, invoiceTransNo, hisTransNo, operateUser, deptCode, deptName, reqDeptCode, reqDeptName, hospitalArea, feeId, feeInfo) values (now(),?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?, ?,?,?)";
|
||
|
return DataBase.insertBatch(sql, ps -> {
|
||
|
for (Recipe recipe : recipeList) {
|
||
|
ps.setInt(1, recipe.getHisStatus());
|
||
|
ps.setInt(2, recipe.getPayStatus());
|
||
|
ps.setString(3, recipe.getOpenid());
|
||
|
ps.setString(4, recipe.getPatientId());
|
||
|
ps.setString(5, recipe.getPayWay());
|
||
|
ps.setBigDecimal(6, recipe.getPayMoney());
|
||
|
ps.setBigDecimal(7, recipe.getTotalFee());
|
||
|
//
|
||
|
ps.setString(8, recipe.getOutTradeNo());
|
||
|
ps.setString(9, recipe.getBankTransNo());
|
||
|
ps.setString(10, recipe.getTradeNo());
|
||
|
ps.setString(11, recipe.getRecipeId());
|
||
|
ps.setString(12, recipe.getTreatNum());
|
||
|
ps.setString(13, recipe.getAuthCode());
|
||
|
ps.setString(14, recipe.getInvoiceTransNo());
|
||
|
ps.setString(15, recipe.getHisTransNo());
|
||
|
ps.setString(16, recipe.getOperateUser());
|
||
|
|
||
|
ps.setString(17, recipe.getDeptCode());
|
||
|
ps.setString(18, recipe.getDeptName());
|
||
|
ps.setString(19, recipe.getReqDeptCode());
|
||
|
ps.setString(20, recipe.getReqDeptName());
|
||
|
ps.setString(21, recipe.getHospitalArea());
|
||
|
ps.setString(22, recipe.getFeeId());
|
||
|
ps.setString(23, recipe.getFeeInfo());
|
||
|
ps.addBatch();
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 查询同一次支付的所有处方信息(多处方一次支付,多张发票)
|
||
|
*
|
||
|
* @param outTradeNo 订单号
|
||
|
*/
|
||
|
public List<Recipe> selectListByOutTradeNo(String outTradeNo) {
|
||
|
String sql = "select * from pay where outTradeNo= ?";
|
||
|
|
||
|
return DataBase.select(sql, Recipe.class, ps -> {
|
||
|
ps.setString(1, outTradeNo);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 查询同一次支付的所有处方信息(多处方一次支付,多张发票)
|
||
|
*
|
||
|
* @param outTradeNo 订单号
|
||
|
*/
|
||
|
public Recipe selectOneByOutTradeNo(String outTradeNo) {
|
||
|
List<Recipe> recipes = selectListByOutTradeNo(outTradeNo);
|
||
|
if (recipes.size() == 1) {
|
||
|
return recipes.get(0);
|
||
|
}
|
||
|
if (recipes.size() > 1) {
|
||
|
log.info("[处方]查询数量大于1 outTradeNo={}", outTradeNo);
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 查询处方
|
||
|
*
|
||
|
* @param tradeNo His交易流水号(医保订单号)
|
||
|
*/
|
||
|
public Recipe selectByTradeNo(String tradeNo) {
|
||
|
String sql = "select * from pay where tradeNo=?";
|
||
|
List<Recipe> dataList = DataBase.select(sql, Recipe.class, ps -> {
|
||
|
ps.setString(1, tradeNo);
|
||
|
});
|
||
|
|
||
|
if (dataList.size() == 1) {
|
||
|
return dataList.get(0);
|
||
|
}
|
||
|
if (dataList.size() > 1) {
|
||
|
log.info("查询数量大于1 tradeNo={}", tradeNo);
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 查询订单状态异常订单
|
||
|
*
|
||
|
* @param bankTransNo 订单号
|
||
|
*/
|
||
|
public Recipe selectStatusErrOrder(String bankTransNo, String tradeNo, String timePoint) {
|
||
|
String sql = "select * from pay where bankTransNo= ? and tradeNo=? and updateTime < ? and hisStatus != 0";
|
||
|
List<Recipe> dataList = DataBase.select(sql, Recipe.class, ps -> {
|
||
|
ps.setString(1, bankTransNo);
|
||
|
ps.setString(2, tradeNo);
|
||
|
ps.setString(3, timePoint);
|
||
|
});
|
||
|
|
||
|
if (dataList.size() == 1) {
|
||
|
return dataList.get(0);
|
||
|
}
|
||
|
if (dataList.size() > 1) {
|
||
|
log.info("查询数量大于1 tradeNo={}, bankTransNo={}", tradeNo, bankTransNo);
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 查询同一次支付的所有处方信息(多处方一次支付,多张发票)
|
||
|
*
|
||
|
* @param treatNum 订单号组
|
||
|
*/
|
||
|
public List<Order> selectByTreatNum(String treatNum) {
|
||
|
String sql = "select updateTime, bankTransNo from pay where payStatus=0 and treatNum= ? order by updateTime desc";
|
||
|
return DataBase.select(sql, Order.class, ps -> {
|
||
|
ps.setString(1, treatNum);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 收到通知后,记录通知信息和HIS交易流水号
|
||
|
*
|
||
|
* @param outTradeNo 订单号组
|
||
|
* @param bankTransNo bankTransNo
|
||
|
*/
|
||
|
public boolean updateNotifyPaid(String outTradeNo, String bankTransNo, String bankMerchantNo, List<Recipe> recipeList) {
|
||
|
List<Order> hisTradeNoList = HisHelper.getHisTradeNo(bankTransNo,
|
||
|
recipeList.stream().map(Order::getId).collect(Collectors.toList()),
|
||
|
PEnum.RECIPE);
|
||
|
|
||
|
List<String> idList = new ArrayList<>();
|
||
|
Map<String, List<Map<String, Object>>> setByCaseList = new HashMap<>();
|
||
|
|
||
|
Map<String, Object> setMap = new HashMap<>();
|
||
|
setMap.put("payStatus", "0");
|
||
|
setMap.put("updateTime", "now()");
|
||
|
setMap.put("bankTransNo", bankTransNo);
|
||
|
setMap.put("bankMerchantNo", bankMerchantNo);
|
||
|
|
||
|
List<Map<String, Object>> caseList = new ArrayList<>();
|
||
|
Map<String, Object> item;
|
||
|
String id, tradeNo;
|
||
|
for (Order orderItem : hisTradeNoList) {
|
||
|
id = String.valueOf(orderItem.getId());
|
||
|
idList.add(id);
|
||
|
item = new HashMap<>();
|
||
|
tradeNo = orderItem.getTradeNo();
|
||
|
item.put(id, tradeNo);
|
||
|
for (Recipe recipe : recipeList) {
|
||
|
if (id.equals(String.valueOf(recipe.getId()))) {
|
||
|
recipe.setTradeNo(tradeNo);
|
||
|
}
|
||
|
}
|
||
|
caseList.add(item);
|
||
|
}
|
||
|
setByCaseList.put("tradeNo", caseList);
|
||
|
|
||
|
Map<String, Object> whereMap = new HashMap<>();
|
||
|
whereMap.put("outTradeNo", outTradeNo);
|
||
|
|
||
|
return DataBase.updateBatch("pay", setMap, setByCaseList, whereMap, idList) > 0;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 医保支付成功更新状态
|
||
|
*
|
||
|
* @param tradeNo 医保订单号
|
||
|
*/
|
||
|
public boolean updateMerPaidByTradeNo(String tradeNo, String bankTransNo) {
|
||
|
String sql = "update pay set payStatus= 0, bankTransNo=?, updateTime=now() where tradeNo=?";
|
||
|
return DataBase.update(sql, ps -> {
|
||
|
ps.setString(1, bankTransNo);
|
||
|
ps.setString(2, tradeNo);
|
||
|
}) > 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* [医保]更新单张处方支付信息
|
||
|
*
|
||
|
* @param tradeNo HIS交易流水号
|
||
|
* @param hisTransNo His返回流水号
|
||
|
* @param invoiceTransNo HIS发票号
|
||
|
*/
|
||
|
public boolean updateHisPaidByTradeNo(String tradeNo, String hisTransNo, String invoiceTransNo) {
|
||
|
String sql = "update pay set HISTransNo=?, InvoiceTransNo=?, PayStatus=0, HisStatus=0 where tradeNo= ?";
|
||
|
return DataBase.update(sql, ps -> {
|
||
|
ps.setString(1, hisTransNo);
|
||
|
ps.setString(2, invoiceTransNo);
|
||
|
ps.setString(3, tradeNo);
|
||
|
}) > 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
// /**
|
||
|
// * 记录His缴费失败的错误信息
|
||
|
// *
|
||
|
// * @param outTradeNo 订单号组
|
||
|
// * @param recipeId 处方id
|
||
|
// * @param hisStatus HIS调用失败码
|
||
|
// * @param hisResult HIS失败说明
|
||
|
// * @return 是否成功
|
||
|
// */
|
||
|
// public boolean updateHisPaidFail(String outTradeNo, String recipeId, String hisStatus, String hisResult) {
|
||
|
// String sql = "update pay set hisStatus=?, hisResult=? where outTradeNo= ? and recipeId= ?";
|
||
|
// return DataBase.update(sql, ps -> {
|
||
|
// ps.setString(1, hisStatus);
|
||
|
// ps.setString(2, hisResult);
|
||
|
// ps.setString(3, outTradeNo);
|
||
|
// ps.setString(4, recipeId);
|
||
|
// }) > 0;
|
||
|
// }
|
||
|
|
||
|
/**
|
||
|
* [医保]记录His缴费失败的错误信息
|
||
|
*
|
||
|
* @param tradeNo HIS交易流水号
|
||
|
* @param hisStatus HIS调用失败码
|
||
|
* @param hisResult HIS失败说明
|
||
|
* @return 是否成功
|
||
|
*/
|
||
|
public boolean updateHisPaidFailByTradeNo(String tradeNo, String hisStatus, String hisResult) {
|
||
|
if (ObjectUtils.isEmpty(tradeNo)) {
|
||
|
return false;
|
||
|
}
|
||
|
String sql = "update pay set hisStatus=?, hisResult=? where tradeNo= ?";
|
||
|
return DataBase.update(sql, ps -> {
|
||
|
ps.setString(1, hisStatus);
|
||
|
ps.setString(2, hisResult);
|
||
|
ps.setString(3, tradeNo);
|
||
|
}) > 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 根据HIS交易流水号查询微信支付成功,His执行失败的并且未退款的记录
|
||
|
*
|
||
|
* @param tradeNo HIS交易流水号
|
||
|
*/
|
||
|
public Recipe selectHisErrorByTradeNo(String tradeNo) {
|
||
|
String sql = "select * from pay where tradeNo= ? and hisStatus= -1 and payStatus = 0 and refundResult is null";
|
||
|
List<Recipe> resultList = DataBase.select(sql, Recipe.class, ps -> {
|
||
|
ps.setString(1, tradeNo);
|
||
|
});
|
||
|
|
||
|
if (resultList.size() == 1) {
|
||
|
return resultList.get(0);
|
||
|
}
|
||
|
if (resultList.size() > 1) {
|
||
|
log.info("[处方]数据库存在多条相同的支付记录 tradeNo={}", tradeNo);
|
||
|
return null;
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 根据HIS交易流水号查询微信支付成功,His执行失败的并且未退款的记录
|
||
|
*
|
||
|
* @param invoiceTransNo HIS交易流水号
|
||
|
*/
|
||
|
public Recipe selectRefundByInvoiceTransNo(String invoiceTransNo, String patientId) {
|
||
|
String sql = "select * from pay where invoiceTransNo= ? and patientId= ? and hisStatus= 0 and payStatus= 0 and authCode is not null and tradeNo is null and (refundResult is null or refundResult != 'OK')";
|
||
|
List<Recipe> resultList = DataBase.select(sql, Recipe.class, ps -> {
|
||
|
ps.setString(1, invoiceTransNo);
|
||
|
ps.setString(2, patientId);
|
||
|
});
|
||
|
|
||
|
if (resultList.size() == 1) {
|
||
|
return resultList.get(0);
|
||
|
}
|
||
|
if (resultList.size() > 1) {
|
||
|
log.info("[处方]数据库存在多条相同的支付记录 invoiceTransNo={}", invoiceTransNo);
|
||
|
return null;
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 根据订单号和处方号查询支付记录
|
||
|
*
|
||
|
* @param outTradeNo 订单号组
|
||
|
* @param recipeId 处方id
|
||
|
*/
|
||
|
public Recipe selectSuccessByOutTradeNoAndRecipeId(String outTradeNo, String recipeId) {
|
||
|
String sql = "select * from pay where outTradeNo= ? and recipeId= ? and hisStatus= 0";
|
||
|
List<Recipe> resultList = DataBase.select(sql, Recipe.class, ps -> {
|
||
|
ps.setString(1, outTradeNo);
|
||
|
ps.setString(2, recipeId);
|
||
|
});
|
||
|
|
||
|
if (resultList.size() == 1) {
|
||
|
return resultList.get(0);
|
||
|
}
|
||
|
if (resultList.size() > 1) {
|
||
|
log.info("数据库存在多条相同的支付记录");
|
||
|
return null;
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 根据His交易流水号查询
|
||
|
*
|
||
|
* @param tradeNo His交易流水号
|
||
|
*/
|
||
|
public Recipe selectRefundByTradeNo(String tradeNo) {
|
||
|
String sql = "select * from pay where tradeNo= ? and payStatus=0 and updateTime is not null";
|
||
|
List<Recipe> resultList = DataBase.select(sql, Recipe.class, ps -> {
|
||
|
ps.setString(1, tradeNo);
|
||
|
});
|
||
|
|
||
|
if (resultList.size() == 1) {
|
||
|
return resultList.get(0);
|
||
|
}
|
||
|
if (resultList.size() > 1) {
|
||
|
log.info("数据库存在多条相同的支付记录");
|
||
|
return null;
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 根据发票流水号号修改退费信息
|
||
|
*
|
||
|
* @param outTradeNo 订单号
|
||
|
* @param recipeId 处方号
|
||
|
* @return 是否成功
|
||
|
*/
|
||
|
public boolean updateRefundByRecipeId(String outTradeNo, String recipeId) {
|
||
|
String sql = "update pay set RefundResult= 0 where outTradeNo=? and recipeId=? and (refundResult is null or refundResult != 'OK')";
|
||
|
return DataBase.update(sql, ps -> {
|
||
|
ps.setString(1, outTradeNo);
|
||
|
ps.setString(2, recipeId);
|
||
|
}) > 0;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 根据发票流水号号修改退费信息
|
||
|
*
|
||
|
* @param bankTransNo 订单号
|
||
|
* @param tradeNo His订单号
|
||
|
* @return 是否成功
|
||
|
*/
|
||
|
public boolean updateHisStatus(String bankTransNo, String tradeNo, String date) {
|
||
|
String sql = "update pay set hisStatus= 0 where bankTransNo=? and tradeNo=? and updateTime < ? and (refundResult is null or refundResult != 'OK')";
|
||
|
return DataBase.update(sql, ps -> {
|
||
|
ps.setString(1, bankTransNo);
|
||
|
ps.setString(2, tradeNo);
|
||
|
ps.setString(3, date);
|
||
|
}) > 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 根据发票流水号号修改退费信息
|
||
|
*
|
||
|
* @param outTradeNo 订单号
|
||
|
* @param invoiceTransNo 发票号
|
||
|
* @param refundResult 退款信息
|
||
|
* @return 是否成功
|
||
|
*/
|
||
|
public boolean updateRefundByInvoiceTransNo(String outTradeNo, String outRefundNo, String invoiceTransNo, String refundResult) {
|
||
|
String sql = "update pay set refundResult=?, tradeNo=? where outTradeNo=? and invoiceTransNo=? and (refundResult is null or refundResult != 'OK')";
|
||
|
return DataBase.update(sql, ps -> {
|
||
|
ps.setString(1, refundResult);
|
||
|
ps.setString(2, outRefundNo);
|
||
|
ps.setString(3, outTradeNo);
|
||
|
ps.setString(4, invoiceTransNo);
|
||
|
}) > 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 根据发订单号和处方号修改退费信息
|
||
|
*
|
||
|
* @param tradeNo His流水号
|
||
|
* @param refundResult 退款信息
|
||
|
* @return 是否成功
|
||
|
*/
|
||
|
public boolean updateRefundRByTradeNo(String tradeNo, String refundResult) {
|
||
|
String sql = "update pay set refundResult=? where tradeNo=? and (refundResult is null or refundResult != 'OK')";
|
||
|
return DataBase.update(sql, ps -> {
|
||
|
ps.setString(1, refundResult);
|
||
|
ps.setString(2, tradeNo);
|
||
|
}) > 0;
|
||
|
}
|
||
|
|
||
|
public List<Order> selectList(String begTime, String endTime) {
|
||
|
String sql = "select * from pay where updateTime between ? and DATE_ADD(?, INTERVAL 1 DAY)";
|
||
|
return DataBase.select(sql, Order.class, ps -> {
|
||
|
ps.setString(1, begTime);
|
||
|
ps.setString(2, endTime);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
// String sql = "select * from pay where openid=? and payStatus = 0 and hisStatus != 0 and updateTime between ? and DATE_ADD(?, INTERVAL 1 DAY) and (RefundResult != 'OK' or RefundResult is null)";
|
||
|
public List<Order> selectRefundList(String openid, String begDate, String endDate) {
|
||
|
String sql = "select * from pay where openid=? and payStatus = 0 and mdTrtId is not null and updateTime between ? and DATE_ADD(?, INTERVAL 1 DAY) and (RefundResult != 'OK' or RefundResult is null)";
|
||
|
return DataBase.select(sql, Order.class, ps -> {
|
||
|
ps.setString(1, openid);
|
||
|
ps.setString(2, begDate);
|
||
|
ps.setString(3, endDate);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
public boolean updateMicroOrderState(String outTradeNo, String bankTransNo, String openid) {
|
||
|
String sql = "update pay set payStatus = 0, bankTransNo=?, openid=? where outTradeNo=? and authCode is not null";
|
||
|
return DataBase.update(sql, ps -> {
|
||
|
ps.setString(1, bankTransNo);
|
||
|
ps.setString(2, openid);
|
||
|
ps.setString(3, outTradeNo);
|
||
|
}) > 0;
|
||
|
}
|
||
|
}
|