|
@@ -768,7 +768,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
if (hadPayable.compareTo(totalPayableRound) != 0) {
|
|
|
throw new MzException("收款金额有误,实际应付" + totalPayableRound.toString() + "元,实收" + hadPayable.toString() + "元,患者处方有修改,请重新刷当前病人收费数据");
|
|
|
}
|
|
|
- getMzChargeDetailService().updateChargeFlag(opId, mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), mzPatientMi.getName(), mzChargeDetailList, now, serialNo, mzReceiptSerial.getChequeType(), null);
|
|
|
+ getMzChargeDetailService().updateChargeFlag(opId, mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), mzPatientMi.getName(), mzChargeDetailList, now, serialNo, null);
|
|
|
getMzChargeDetailService().afterChargeFee(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), mzDepositFileVo.getMzDepositFiles(), now, serialNo, mzReceiptSerial, totalPayable, receiptSerialFee);
|
|
|
if (Constants.JZ_IC_CARD.equals(mzPatientMi.getIcCardNo())) {
|
|
|
mzChargeDetailMapper.updateNameByPatientIdAndTimes(mzPatientMi.getName(), mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes());
|
|
@@ -3216,13 +3216,12 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
* @param mzChargeDetailList
|
|
|
* @param now
|
|
|
* @param serialNo
|
|
|
- * @param chequeType
|
|
|
* @param refundTimes 被退费次数 为null 时是收费
|
|
|
* @throws MzException
|
|
|
*/
|
|
|
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void updateChargeFlag(String opId, String patientId, Integer times, String name, List<MzChargeDetail> mzChargeDetailList, Date now, int serialNo, String chequeType, Integer refundTimes) throws MzException {
|
|
|
+ public void updateChargeFlag(String opId, String patientId, Integer times, String name, List<MzChargeDetail> mzChargeDetailList, Date now, int serialNo, Integer refundTimes) throws MzException {
|
|
|
if (mzChargeDetailList == null || mzChargeDetailList.size() == 0) {
|
|
|
return;
|
|
|
}
|
|
@@ -3402,8 +3401,14 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
updateMzChargeDetail.setConfirmFlag(ConfirmFlagEnum.CANCEL.code);
|
|
|
mzChargeDetailMapper.updateMzChargeDetailFull(updateMzChargeDetail);
|
|
|
BigDecimal totalAmount=mzChargeDetailMapper.selectSumAmount(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), mzDepositFileVo.getReceiptNo());
|
|
|
+ if(totalAmount!=null){
|
|
|
+ totalAmount=totalAmount.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
//本院记账重收的时候。新的收费方式与老的部分收费方式的receiptNo 不一致,所以加这个逻辑
|
|
|
BigDecimal tempAmount=mzDepositFileMapper.selectSumAmount(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), mzDepositFileVo.getReceiptNo());
|
|
|
+ if(tempAmount!=null){
|
|
|
+ tempAmount=tempAmount.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
List<MzReceiptSerial> mzReceiptSerials = mzReceiptSerialMapper.selectSerialForThisTime(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), mzDepositFileVo.getReceiptNo());
|
|
|
if(totalAmount.compareTo(tempAmount)>0){
|
|
|
mzReceiptSerials=mzReceiptSerialMapper.selectReceiptDetailsWithOutByjz(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes());
|
|
@@ -3427,7 +3432,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
int times = 0;
|
|
|
int oriTimes = mzDepositFileVo.getTimes();
|
|
|
if (allRefund) {
|
|
|
- getDeposFiles(opId, mzDepositFileVo, now, 0, 0, totalAmount, null, fullNewMzDepositFiles, allRefund, null);
|
|
|
+ getDeposFiles(opId, mzDepositFileVo, now, 0, 0, totalAmount, fullNewMzDepositFiles, allRefund, null);
|
|
|
if(fullNewMzDepositFiles.size()>0){
|
|
|
//新增收费方式记录 退费的负数冲抵部分
|
|
|
mzDepositFileMapper.batchInsertMzDepositFile(fullNewMzDepositFiles);
|
|
@@ -3487,8 +3492,8 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
ReceiptSerialFee receiptSerialFee = new ReceiptSerialFee();
|
|
|
//退费后新的收款方式
|
|
|
List<MzDepositFile> newMzDepositFiles = new ArrayList<>();
|
|
|
- String payWay = Constants.CASH;
|
|
|
- payWay = getDeposFiles(opId, mzDepositFileVo, now, times, serialNo, totalPayable, payWay, fullNewMzDepositFiles, allRefund, newMzDepositFiles);
|
|
|
+ //String payWay = Constants.CASH;
|
|
|
+ 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());
|
|
@@ -3496,7 +3501,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
Integer refundTimes = mzDepositFileVo.getTimes();
|
|
|
mzDepositFileVo.setTimes(times);
|
|
|
getHadPayable(opId, mzDepositFileVo, windows, mzPatientMi, feeMap, now, serialNo, mzReceiptSerial, 1, receiptSerialFee);
|
|
|
- getMzChargeDetailService().updateChargeFlag(opId, mzDepositFileVo.getPatientId(), times, mzChargeDetails.get(0).getName(), mzChargeDetails, now, serialNo, payWay, refundTimes);
|
|
|
+ getMzChargeDetailService().updateChargeFlag(opId, mzDepositFileVo.getPatientId(), times, mzChargeDetails.get(0).getName(), mzChargeDetails, now, serialNo, refundTimes);
|
|
|
getMzChargeDetailService().afterChargeFee(mzDepositFileVo.getPatientId(), times, fullNewMzDepositFiles, now, serialNo, mzReceiptSerial, totalPayable, receiptSerialFee);
|
|
|
MzPatientMi updateMzPatientMi = new MzPatientMi();
|
|
|
updateMzPatientMi.setPatientId(mzDepositFileVo.getPatientId());
|
|
@@ -3643,12 +3648,11 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
* @param times
|
|
|
* @param serialNo
|
|
|
* @param totalPayable
|
|
|
- * @param payWay
|
|
|
* @param fullNewMzDepositFiles
|
|
|
* @param newMzDepositFiles
|
|
|
* @return
|
|
|
*/
|
|
|
- private String getDeposFiles(String opId, MzDepositFileVo mzDepositFileVo, Date now, int times, int serialNo, BigDecimal totalPayable, String payWay, List<MzDepositFile> fullNewMzDepositFiles, boolean allRefund, List<MzDepositFile> newMzDepositFiles) {
|
|
|
+ private void 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());
|
|
@@ -3656,7 +3660,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
mzDepositFiles=mzDepositFileMapper.selectMzDepositFileByTimesWithOutByjz(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes());
|
|
|
}
|
|
|
if (mzDepositFiles == null || mzDepositFiles.size() == 0) {
|
|
|
- return payWay;
|
|
|
+ return;
|
|
|
}
|
|
|
//本院记账总额
|
|
|
BigDecimal byjzAmount = BigDecimal.ZERO;
|
|
@@ -3664,7 +3668,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
BigDecimal ybjzAmount = BigDecimal.ZERO;
|
|
|
//非本院记账总额
|
|
|
BigDecimal notByjzAmount = BigDecimal.ZERO;
|
|
|
-
|
|
|
+ MzDepositFile temp =null;
|
|
|
for (MzDepositFile ms : mzDepositFiles) {
|
|
|
if (ms == null) {
|
|
|
continue;
|
|
@@ -3676,56 +3680,57 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
}else {
|
|
|
notByjzAmount = notByjzAmount.add(ms.getAmount());
|
|
|
}
|
|
|
-
|
|
|
- MzDepositFile temp = CloneUtil.clone(ms);
|
|
|
+ if(temp!=null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ temp= CloneUtil.clone(ms);
|
|
|
temp.setReceiptNo(-temp.getReceiptNo());
|
|
|
- temp.setAmount(BigDecimal.ZERO.subtract(temp.getAmount()));
|
|
|
+ //temp.setAmount(BigDecimal.ZERO.subtract(temp.getAmount()));
|
|
|
temp.setReceiptSn(-temp.getReceiptSn());
|
|
|
temp.setSerialNo(-temp.getSerialNo());
|
|
|
temp.setDeptNo(null);
|
|
|
temp.setChargeDate(now);
|
|
|
temp.setPayMark(PayMarkEnum.RETURN_PREMIUM.code);
|
|
|
temp.setOpId(opId);
|
|
|
- //当前退费发起人是手机自助,且退费的记录的缴费人也是手机自助发起的缴费记录退费方式
|
|
|
- if (Constants.BRZZJF_CODE.equals(opId) && Constants.BRZZJF_CODE.equals(temp.getOpId())) {
|
|
|
- if(payWay==null){
|
|
|
- payWay = temp.getChequeType();
|
|
|
- }
|
|
|
- } else {
|
|
|
- if(payWay==null && !Constants.BYJZ.equals(ms.getChequeType()) && !Constants.YBJZ.equals(ms.getChequeType())){
|
|
|
- payWay = Constants.CASH;
|
|
|
- temp.setChequeType(payWay);
|
|
|
- }
|
|
|
- }
|
|
|
+// //当前退费发起人是手机自助,且退费的记录的缴费人也是手机自助发起的缴费记录退费方式
|
|
|
+// if (Constants.BRZZJF_CODE.equals(opId) && Constants.BRZZJF_CODE.equals(temp.getOpId())) {
|
|
|
+//// if(payWay==null){
|
|
|
+//// payWay = temp.getChequeType();
|
|
|
+//// }
|
|
|
+// } else {
|
|
|
+// if(!(Constants.BYJZ.equals(ms.getChequeType()) || Constants.YBJZ.equals(ms.getChequeType()))){
|
|
|
+// temp.setChequeType(Constants.CASH);
|
|
|
+// }
|
|
|
+// }
|
|
|
temp.setDcountNo(YesNoEnum.NO.code);
|
|
|
temp.setDcountDate(null);
|
|
|
temp.setPsordnum(null);
|
|
|
temp.setAgtordnum(null);
|
|
|
temp.setHisrefundnum(null);
|
|
|
+ // fullNewMzDepositFiles.add(temp);
|
|
|
+ }
|
|
|
+ //如果有本院记账的退款金额,本院记账记录保持入库
|
|
|
+ if (byjzAmount.compareTo(BigDecimal.ZERO) == 1) {
|
|
|
+ //复制一个本院记账的退款记录
|
|
|
+ MzDepositFile byjzTemp = CloneUtil.clone(temp);
|
|
|
+ byjzTemp.setChequeType(Constants.BYJZ);
|
|
|
+ byjzTemp.setAmount(BigDecimal.ZERO.subtract(byjzAmount));
|
|
|
+ fullNewMzDepositFiles.add(byjzTemp);
|
|
|
+ }
|
|
|
+ //如果有医保记账的退款金额,医保记账记录保持入库
|
|
|
+ if (ybjzAmount.compareTo(BigDecimal.ZERO) == 1) {
|
|
|
+ //复制一个医保记账的退款记录
|
|
|
+ MzDepositFile ybjzTemp = CloneUtil.clone(temp);
|
|
|
+ ybjzTemp.setChequeType(Constants.YBJZ);
|
|
|
+ ybjzTemp.setAmount(BigDecimal.ZERO.subtract(ybjzAmount));
|
|
|
+ fullNewMzDepositFiles.add(ybjzTemp);
|
|
|
+ }
|
|
|
+ //如果有非本院记账的退款金额,非本院记账记录保持入库
|
|
|
+ if (notByjzAmount.compareTo(BigDecimal.ZERO) == 1) {
|
|
|
+ temp.setChequeType(Constants.CASH);
|
|
|
+ temp.setAmount(BigDecimal.ZERO.subtract(notByjzAmount));
|
|
|
fullNewMzDepositFiles.add(temp);
|
|
|
-
|
|
|
}
|
|
|
-// temp.setAmount(BigDecimal.ZERO.subtract(notByjzAmount));
|
|
|
-// //复制一个本院记账的退款记录
|
|
|
-// MzDepositFile byjzTemp = CloneUtil.clone(temp);
|
|
|
-// byjzTemp.setChequeType(Constants.BYJZ);
|
|
|
-// byjzTemp.setAmount(BigDecimal.ZERO.subtract(byjzAmount));
|
|
|
-// //如果有本院记账的退款金额,本院记账记录保持入库
|
|
|
-// if (byjzAmount.compareTo(BigDecimal.ZERO) == 1) {
|
|
|
-// fullNewMzDepositFiles.add(byjzTemp);
|
|
|
-// }
|
|
|
-// //复制一个医保记账的退款记录
|
|
|
-// MzDepositFile ybjzTemp = CloneUtil.clone(temp);
|
|
|
-// ybjzTemp.setChequeType(Constants.YBJZ);
|
|
|
-// ybjzTemp.setAmount(BigDecimal.ZERO.subtract(ybjzAmount));
|
|
|
-// //如果有医保记账的退款金额,医保记账记录保持入库
|
|
|
-// if (ybjzAmount.compareTo(BigDecimal.ZERO) == 1) {
|
|
|
-// fullNewMzDepositFiles.add(ybjzTemp);
|
|
|
-// }
|
|
|
-// //如果有非本院记账的退款金额,非本院记账记录保持入库
|
|
|
-// if (notByjzAmount.compareTo(BigDecimal.ZERO) == 1) {
|
|
|
-// fullNewMzDepositFiles.add(temp);
|
|
|
-// }
|
|
|
if (!allRefund) {
|
|
|
MzDepositFile m = mzDepositFiles.get(0);
|
|
|
m.setTimes(times);
|
|
@@ -3745,7 +3750,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
m.setAmount(totalPayable);
|
|
|
m.setChequeType(Constants.CASH);
|
|
|
fullNewMzDepositFiles.add(m);
|
|
|
- payWay = Constants.CASH;
|
|
|
+ //payWay = Constants.CASH;
|
|
|
newMzDepositFiles.add(m);
|
|
|
//应付大于实际已经支付的非记账总额,需要用记账收一部分
|
|
|
} else if (totalPayable.compareTo(notByjzAmount) == 1) {
|
|
@@ -3761,10 +3766,10 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
byjzNeedPayTemp.setAmount(totalPayable.subtract(notByjzAmount).setScale(1, BigDecimal.ROUND_HALF_UP));
|
|
|
fullNewMzDepositFiles.add(byjzNeedPayTemp);
|
|
|
newMzDepositFiles.add(byjzNeedPayTemp);
|
|
|
- payWay = Constants.BYJZ;
|
|
|
+ // payWay = Constants.BYJZ;
|
|
|
}
|
|
|
}
|
|
|
- return payWay;
|
|
|
+ // return payWay;
|
|
|
}
|
|
|
|
|
|
/**
|