|
@@ -3377,7 +3377,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
|
|
|
@Override
|
|
|
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
|
|
|
- public int refundFee(String opId, MzDepositFileVo mzDepositFileVo, String ipAddress) throws MzException {
|
|
|
+ public Map<String,Object> refundFee(String opId, MzDepositFileVo mzDepositFileVo, String ipAddress) throws MzException {
|
|
|
Windows windows = windowsMapper.selectLastWindowsByIpAddress(ipAddress);
|
|
|
if (windows == null) {
|
|
|
throw new MzException("当前操作人未设置窗口号,请先设置!");
|
|
@@ -3438,8 +3438,9 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
List<MzDepositFile> fullNewMzDepositFiles = new ArrayList<>();
|
|
|
int times = 0;
|
|
|
int oriTimes = mzDepositFileVo.getTimes();
|
|
|
+ List<MzDepositFile> needRefundList =null;
|
|
|
if (allRefund) {
|
|
|
- getDeposFiles(opId, mzDepositFileVo, now, 0, 0, totalAmount, fullNewMzDepositFiles, allRefund, null);
|
|
|
+ needRefundList = getDeposFiles(opId, mzDepositFileVo, now, 0, 0, totalAmount, fullNewMzDepositFiles, allRefund, null);
|
|
|
if (fullNewMzDepositFiles.size() > 0) {
|
|
|
//新增收费方式记录 退费的负数冲抵部分
|
|
|
mzDepositFileMapper.batchInsertMzDepositFile(fullNewMzDepositFiles);
|
|
@@ -3503,7 +3504,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
//退费后新的收款方式
|
|
|
List<MzDepositFile> newMzDepositFiles = new ArrayList<>();
|
|
|
//String payWay = Constants.CASH;
|
|
|
- getDeposFiles(opId, mzDepositFileVo, now, times, serialNo, totalPayable, fullNewMzDepositFiles, allRefund, newMzDepositFiles);
|
|
|
+ needRefundList =getDeposFiles(opId, mzDepositFileVo, now, times, serialNo, totalPayable, fullNewMzDepositFiles, allRefund, newMzDepositFiles);
|
|
|
//setMzReceiptSerial(opId, mzDepositFileVo.getPatientId(), times, windows, mzChargeDetails.get(0).getResponceType(), feeMap, now, serialNo, mzReceiptSerial, payWay, totalPayable, 1);
|
|
|
MzPatientMi mzPatientMi = mzPatientMiService.queryByPatientId(mzDepositFileVo.getPatientId());
|
|
|
Clinic dbClinic = clinicMapper.selectByPatientIdAndTimesAndReceiptNo(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), mzDepositFileVo.getReceiptNo());
|
|
@@ -3550,7 +3551,10 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
MzYjReq updateMzYjReq = new MzYjReq(mzDepositFileVo.getPatientId(), oriTimes);
|
|
|
updateMzYjReq.setPayMark(PayMarkEnum.RETURN_PREMIUM.code);
|
|
|
mzYjReqService.modifyMzYjReq(updateMzYjReq);
|
|
|
- return times;
|
|
|
+ Map<String,Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("times",times);
|
|
|
+ resultMap.put("needRefundList",needRefundList);
|
|
|
+ return resultMap;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -3662,7 +3666,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
* @param newMzDepositFiles
|
|
|
* @return
|
|
|
*/
|
|
|
- private void getDeposFiles(String opId, MzDepositFileVo mzDepositFileVo, Date now, int times, int serialNo, BigDecimal totalPayable, List<MzDepositFile> fullNewMzDepositFiles, boolean allRefund, List<MzDepositFile> newMzDepositFiles) {
|
|
|
+ private List<MzDepositFile> getDeposFiles(String opId, MzDepositFileVo mzDepositFileVo, Date now, int times, int serialNo, BigDecimal totalPayable, List<MzDepositFile> fullNewMzDepositFiles, boolean allRefund, List<MzDepositFile> newMzDepositFiles) {
|
|
|
List<MzDepositFile> mzDepositFiles = mzDepositFileMapper.selectMzDepositFileByTimes(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), mzDepositFileVo.getReceiptNo(), "mz_deposit_file");
|
|
|
//本院记账重收的时候。新的收费方式与老的部分收费方式的receiptNo 不一致,所以加这个逻辑
|
|
|
BigDecimal tempAmount = mzDepositFileMapper.selectSumAmount(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), mzDepositFileVo.getReceiptNo());
|
|
@@ -3670,7 +3674,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
mzDepositFiles = mzDepositFileMapper.selectMzDepositFileByTimesWithOutByjz(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes());
|
|
|
}
|
|
|
if (mzDepositFiles == null || mzDepositFiles.size() == 0) {
|
|
|
- return;
|
|
|
+ return null;
|
|
|
}
|
|
|
//本院记账总额
|
|
|
BigDecimal byjzAmount = BigDecimal.ZERO;
|
|
@@ -3683,6 +3687,8 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
//非本院记账总额
|
|
|
BigDecimal notByjzAmount = BigDecimal.ZERO;
|
|
|
MzDepositFile temp = null;
|
|
|
+ //需要调用银行接口退费的集合
|
|
|
+ List<MzDepositFile> needRefundList = new ArrayList<>();
|
|
|
for (MzDepositFile ms : mzDepositFiles) {
|
|
|
if (ms == null) {
|
|
|
continue;
|
|
@@ -3695,6 +3701,20 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
pGrzhAmount = pGrzhAmount.add(ms.getAmount());
|
|
|
} else if (Constants.SSHIYBGZ.equals(ms.getChequeType())) {
|
|
|
tGrzhAmount = tGrzhAmount.add(ms.getAmount());
|
|
|
+ } else if (Constants.YLK.equals(ms.getChequeType()) || Constants.JHZF.equals(ms.getChequeType())){
|
|
|
+ needRefundList.add(ms);
|
|
|
+ //直接创建负数的
|
|
|
+ MzDepositFile refundMzDepositFile=CloneUtil.clone(ms);
|
|
|
+ refundMzDepositFile.setReceiptNo(-refundMzDepositFile.getReceiptNo());
|
|
|
+ refundMzDepositFile.setAmount(BigDecimal.ZERO.subtract(refundMzDepositFile.getAmount()));
|
|
|
+ refundMzDepositFile.setReceiptSn(-refundMzDepositFile.getReceiptSn());
|
|
|
+ refundMzDepositFile.setSerialNo(-refundMzDepositFile.getSerialNo());
|
|
|
+ refundMzDepositFile.setDeptNo(null);
|
|
|
+ refundMzDepositFile.setChargeDate(now);
|
|
|
+ refundMzDepositFile.setPayMark(PayMarkEnum.RETURN_PREMIUM.code);
|
|
|
+ refundMzDepositFile.setOpId(opId);
|
|
|
+ refundMzDepositFile.setDcountNo(YesNoEnum.NO.code);
|
|
|
+ fullNewMzDepositFiles.add(refundMzDepositFile);
|
|
|
} else {
|
|
|
notByjzAmount = notByjzAmount.add(ms.getAmount());
|
|
|
}
|
|
@@ -3725,6 +3745,8 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
temp.setPsordnum(null);
|
|
|
temp.setAgtordnum(null);
|
|
|
temp.setHisrefundnum(null);
|
|
|
+ temp.setParChannel(null);
|
|
|
+ temp.setTransDate(null);
|
|
|
// fullNewMzDepositFiles.add(temp);
|
|
|
}
|
|
|
//如果有本院记账的退款金额,本院记账记录保持入库
|
|
@@ -3803,7 +3825,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
// payWay = Constants.BYJZ;
|
|
|
}
|
|
|
}
|
|
|
- // return payWay;
|
|
|
+ return needRefundList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -4219,6 +4241,23 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
}
|
|
|
m.setResponceType(null);
|
|
|
}
|
|
|
+ if(StringUtils.isBlank(m.getChequeType())){
|
|
|
+ throw new MzException("付款方式为空!");
|
|
|
+ }
|
|
|
+ if (Constants.JHZF.equals(m.getChequeType()) || Constants.YLK.equals(m.getChequeType())) {
|
|
|
+ if (StringUtils.isBlank(m.getPsordnum())) {
|
|
|
+ throw new MzException("银联刷卡或者聚合支付流水号为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(m.getParChannel())) {
|
|
|
+ throw new MzException("银联刷卡或者聚合支付回传支付渠道为空");
|
|
|
+ }
|
|
|
+ if (Constants.JHZF.equals(m.getChequeType()) && StringUtils.isBlank(m.getAgtordnum())) {
|
|
|
+ throw new MzException("银联刷卡或者聚合支付条形码流水号为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(m.getTransDate())) {
|
|
|
+ throw new MzException("银联刷卡或者聚合支付交易日期为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
if (m.getPatientId() == null) {
|
|
|
//此时是直接收费,需要设置相关参数
|
|
|
m.setPatientId(mzDepositFileVo.getPatientId());
|