|  | @@ -6,6 +6,7 @@ import cn.hnthyy.thmz.common.Constants;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.common.SpringUtil;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.entity.MzException;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.entity.his.*;
 | 
	
		
			
				|  |  | +import cn.hnthyy.thmz.entity.thmz.PayInfo;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.entity.thmz.Windows;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.enums.*;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.mapper.his.*;
 | 
	
	
		
			
				|  | @@ -13,6 +14,7 @@ import cn.hnthyy.thmz.mapper.thmz.WindowsMapper;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.pageDto.MzChargeDetailPageDto;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.service.his.*;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.service.thmz.OrderStatusChangeService;
 | 
	
		
			
				|  |  | +import cn.hnthyy.thmz.service.thmz.TsmzService;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.vo.MzDepositFileVo;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.vo.MzPrescriptionVo;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.vo.ThmzmxsrParamsVo;
 | 
	
	
		
			
				|  | @@ -106,6 +108,11 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
 | 
	
		
			
				|  |  |      @SuppressWarnings("all")
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private YpBaseYfMapper ypBaseYfMapper;
 | 
	
		
			
				|  |  | +    @SuppressWarnings("all")
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private MzChargeDetailYbMapper mzChargeDetailYbMapper;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private TsmzService tsmzService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public int countMzChargeDetail(MzChargeDetailPageDto mzChargeDetailPageDto) {
 | 
	
	
		
			
				|  | @@ -1026,6 +1033,14 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
 | 
	
		
			
				|  |  |          List<MzChargeDetail> mzChargeDetails = getNewListForRefundFee(opId, mzDepositFileVo, YesNoEnum.YES);
 | 
	
		
			
				|  |  |          //是否全退
 | 
	
		
			
				|  |  |          boolean allRefund = mzChargeDetails == null || mzChargeDetails.size() == 0;
 | 
	
		
			
				|  |  | +        MzChargeDetailYb mzChargeDetailYb = new  MzChargeDetailYb();
 | 
	
		
			
				|  |  | +        mzChargeDetailYb.setPatientId(mzDepositFileVo.getPatientId());
 | 
	
		
			
				|  |  | +        mzChargeDetailYb.setTimes(mzDepositFileVo.getTimes());
 | 
	
		
			
				|  |  | +        mzChargeDetailYb.setReceiptNo(mzDepositFileVo.getReceiptNo());
 | 
	
		
			
				|  |  | +        int count = mzChargeDetailYbMapper.selectTmCount(mzChargeDetailYb);
 | 
	
		
			
				|  |  | +        if(count>0 && !allRefund){
 | 
	
		
			
				|  |  | +            throw new MzException("退费失败,特门收费必须全退!");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          List<String> chargeItemCodeList = mzChargeDetails.stream().filter(u -> StringUtils.isNotBlank(u.getChargeItemCode())).map(u -> u.getChargeItemCode()).collect(Collectors.toList());
 | 
	
		
			
				|  |  |          List<MzChargeDetail> oriMzChargeDetails = mzChargeDetailMapper.selectMzChargeDetailByPatientId(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), mzDepositFileVo.getReceiptNo(), PayMarkEnum.CHARGED.code);
 | 
	
		
			
				|  |  |          Date now = new Date();
 | 
	
	
		
			
				|  | @@ -1058,6 +1073,10 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
 | 
	
		
			
				|  |  |              //新增收费方式记录
 | 
	
		
			
				|  |  |              mzDepositFileMapper.batchInsertMzDepositFile(fullNewMzDepositFiles);
 | 
	
		
			
				|  |  |              times = 0;
 | 
	
		
			
				|  |  | +            if(count>0){
 | 
	
		
			
				|  |  | +                //PayInfo result=
 | 
	
		
			
				|  |  | +                tsmzService.retractFees(opId, mzChargeDetailYb.getPatientId(),mzChargeDetailYb.getTimes(),mzChargeDetailYb.getReceiptNo());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  |              times = mzChargeDetails.get(0).getTimes();
 | 
	
		
			
				|  |  |              List<String> orderCodes = new ArrayList<>();
 |