|
|
@@ -8,6 +8,7 @@ import cn.hnthyy.thmz.common.Constants;
|
|
|
import cn.hnthyy.thmz.common.exception.BizException;
|
|
|
import cn.hnthyy.thmz.entity.his.mz.JcJyItemCharge;
|
|
|
import cn.hnthyy.thmz.entity.his.mz.MzChargeDetail;
|
|
|
+import cn.hnthyy.thmz.entity.his.mz.MzDepositFile;
|
|
|
import cn.hnthyy.thmz.entity.his.mz.MzVisitTable;
|
|
|
import cn.hnthyy.thmz.entity.his.mz.MzYjReq;
|
|
|
import cn.hnthyy.thmz.entity.his.mz.ZdDiscountDetail;
|
|
|
@@ -18,12 +19,14 @@ import cn.hnthyy.thmz.entity.thmz.Config;
|
|
|
import cn.hnthyy.thmz.entity.thmz.Discount;
|
|
|
import cn.hnthyy.thmz.entity.thmz.Template;
|
|
|
import cn.hnthyy.thmz.enums.NumberEnum;
|
|
|
+import cn.hnthyy.thmz.enums.PayMarkEnum;
|
|
|
import cn.hnthyy.thmz.enums.YesNoEnum;
|
|
|
import cn.hnthyy.thmz.mapper.his.zd.JcJyItemChargeMapper;
|
|
|
import cn.hnthyy.thmz.mapper.his.zd.ZdChargeItemMapper;
|
|
|
import cn.hnthyy.thmz.mapper.thmz.ConfigMapper;
|
|
|
import cn.hnthyy.thmz.mapper.thmz.DiscountMapper;
|
|
|
import cn.hnthyy.thmz.service.his.mz.MzChargeDetailService;
|
|
|
+import cn.hnthyy.thmz.service.his.mz.MzDepositFileService;
|
|
|
import cn.hnthyy.thmz.service.his.mz.MzVisitTableService;
|
|
|
import cn.hnthyy.thmz.service.his.mz.MzYjReqService;
|
|
|
import cn.hnthyy.thmz.service.his.mz.ShareholderCardService;
|
|
|
@@ -92,6 +95,8 @@ public class DiscountServiceImpl implements DiscountService {
|
|
|
private DictDataService dictDataService;
|
|
|
@Resource
|
|
|
private MzYjReqService mzYjReqService;
|
|
|
+ @Resource
|
|
|
+ private MzDepositFileService mzDepositFileService;
|
|
|
|
|
|
/**
|
|
|
* 缓存
|
|
|
@@ -699,58 +704,71 @@ public class DiscountServiceImpl implements DiscountService {
|
|
|
AssertUtil.isNotBlank(patientId,"门诊号不能为空");
|
|
|
AssertUtil.isNotBlank(times,"就诊次数不能为空");
|
|
|
AssertUtil.isNotBlank(chargeCodes,"项目编码不能为空");
|
|
|
- MzVisitTable mzVisitTable = mzVisitTableService.queryByPatientIdAndTimes(patientId,times);
|
|
|
- if(mzVisitTable == null){
|
|
|
- throw new BizException("没有就诊记录");
|
|
|
- }
|
|
|
- List<Clinic> clinicList = clinicService.queryByPatientIdAndTimes(patientId, times);
|
|
|
- String zyDiscountGroup = dictDataService.queryDictVlaue("2.0","zy_discount_group","81");
|
|
|
- List<String> zyDiscountGroups = CollUtil.newArrayList(zyDiscountGroup.split(","));
|
|
|
- List<String> zyItemCodes = zdChargeItemMapper.selectZyChargeCodes(Tools.toInStringSql(zyDiscountGroups), Tools.toInStringSql(chargeCodes));
|
|
|
- List<MzYjReq> mzYjReqs = mzYjReqService.queryPatientIdAndTimes(patientId, times);
|
|
|
- if(CollUtil.isNotEmpty(mzYjReqs)){
|
|
|
- for(MzYjReq mzYjReq : mzYjReqs){
|
|
|
- List<String> itemCodes = getItemCodes(mzYjReq.getOrderCode(), mzYjReq.getReqType());
|
|
|
- if(CollUtil.containsAll(chargeCodes,itemCodes)){
|
|
|
- for(String item :chargeCodes){
|
|
|
- if(itemCodes.contains(item)){
|
|
|
- item = item + "," + mzYjReq.getOrderCode();
|
|
|
+ //看是否收费
|
|
|
+ MzDepositFile mzDepositFile = new MzDepositFile();
|
|
|
+ mzDepositFile.setPatientId(patientId);
|
|
|
+ mzDepositFile.setTimes(times);
|
|
|
+ mzDepositFile.setPayMark(PayMarkEnum.CHARGED.code);
|
|
|
+ List<MzDepositFile> mzDepositFiles = mzDepositFileService.queryMzDepositFileByTimesAndPayMark(mzDepositFile);
|
|
|
+ if(CollUtil.isNotEmpty(mzDepositFiles)){
|
|
|
+ MzChargeDetail totalFee = mzChargeDetailService.querySumTotalFee(patientId,times);
|
|
|
+ if(totalFee != null && Convert.toBigDecimal(totalFee.getAmount(),BigDecimal.ZERO).compareTo(Convert.toBigDecimal(totalFee.getNotDiscountAmount(),BigDecimal.ZERO)) < 0){
|
|
|
+ throw new BizException("项目有优惠",-2);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ MzVisitTable mzVisitTable = mzVisitTableService.queryByPatientIdAndTimes(patientId,times);
|
|
|
+ if(mzVisitTable == null){
|
|
|
+ throw new BizException("没有就诊记录");
|
|
|
+ }
|
|
|
+ List<Clinic> clinicList = clinicService.queryByPatientIdAndTimes(patientId, times);
|
|
|
+ String zyDiscountGroup = dictDataService.queryDictVlaue("2.0","zy_discount_group","81");
|
|
|
+ List<String> zyDiscountGroups = CollUtil.newArrayList(zyDiscountGroup.split(","));
|
|
|
+ List<String> zyItemCodes = zdChargeItemMapper.selectZyChargeCodes(Tools.toInStringSql(zyDiscountGroups), Tools.toInStringSql(chargeCodes));
|
|
|
+ List<MzYjReq> mzYjReqs = mzYjReqService.queryPatientIdAndTimes(patientId, times);
|
|
|
+ if(CollUtil.isNotEmpty(mzYjReqs)){
|
|
|
+ for(MzYjReq mzYjReq : mzYjReqs){
|
|
|
+ List<String> itemCodes = getItemCodes(mzYjReq.getOrderCode(), mzYjReq.getReqType());
|
|
|
+ if(CollUtil.containsAll(chargeCodes,itemCodes)){
|
|
|
+ for(String item :chargeCodes){
|
|
|
+ if(itemCodes.contains(item)){
|
|
|
+ item = item + "," + mzYjReq.getOrderCode();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- Map<String, ZdDiscountDetail> gdDiscount = shareholderCardService.getChargeItemCodesDiscountDetail(patientId, times, 0, null, chargeCodes, zyItemCodes);
|
|
|
- if(CollUtil.isNotEmpty(gdDiscount)){
|
|
|
- throw new BizException("项目有股东卡优惠",-2);
|
|
|
- }
|
|
|
- Map<String, BigDecimal> tcqyDiscountRate = getTcDiscountRate(2, null, chargeCodes);
|
|
|
- if(!(CollUtil.isNotEmpty(clinicList) && clinicList.stream().anyMatch(item->Convert.toInt(item.getZgmztczf(),0)==1)) && CollUtil.isNotEmpty(tcqyDiscountRate)){
|
|
|
- throw new BizException("项目有套餐优惠",-2);
|
|
|
- }
|
|
|
- if(!(CollUtil.isNotEmpty(clinicList) && clinicList.stream().anyMatch(item->Convert.toInt(item.getZgmztczf(),0)==1)) && StrUtil.isNotBlank(mzVisitTable.getVisitDeptCode())){
|
|
|
- Map<String, BigDecimal> tcDeptDiscountRate = getTcDiscountRate(0, mzVisitTable.getVisitDeptCode(), chargeCodes);
|
|
|
- if(CollUtil.isNotEmpty(tcDeptDiscountRate)){
|
|
|
+ Map<String, ZdDiscountDetail> gdDiscount = shareholderCardService.getChargeItemCodesDiscountDetail(patientId, times, 0, null, chargeCodes, zyItemCodes);
|
|
|
+ if(CollUtil.isNotEmpty(gdDiscount)){
|
|
|
+ throw new BizException("项目有股东卡优惠",-2);
|
|
|
+ }
|
|
|
+ Map<String, BigDecimal> tcqyDiscountRate = getTcDiscountRate(2, null, chargeCodes);
|
|
|
+ if(!(CollUtil.isNotEmpty(clinicList) && clinicList.stream().anyMatch(item->Convert.toInt(item.getZgmztczf(),0)==1)) && CollUtil.isNotEmpty(tcqyDiscountRate)){
|
|
|
throw new BizException("项目有套餐优惠",-2);
|
|
|
}
|
|
|
- }
|
|
|
- boolean flag = false;
|
|
|
- for(String code : chargeCodes){
|
|
|
- Discount discount = getDiscountRate(2,null,code);
|
|
|
- if(!(CollUtil.isNotEmpty(clinicList) && clinicList.stream().anyMatch(item->Convert.toInt(item.getZgmztczf(),0)==1)) && discount != null){
|
|
|
- flag = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- if(StrUtil.isNotBlank(mzVisitTable.getVisitDeptCode())){
|
|
|
- discount = getDiscountRate(0, mzVisitTable.getVisitDeptCode(),code);
|
|
|
- if(!(CollUtil.isNotEmpty(clinicList) && clinicList.stream().anyMatch(item->Convert.toInt(item.getZgmztczf(),0)==1)) && discount !=null){
|
|
|
+ if(!(CollUtil.isNotEmpty(clinicList) && clinicList.stream().anyMatch(item->Convert.toInt(item.getZgmztczf(),0)==1)) && StrUtil.isNotBlank(mzVisitTable.getVisitDeptCode())){
|
|
|
+ Map<String, BigDecimal> tcDeptDiscountRate = getTcDiscountRate(0, mzVisitTable.getVisitDeptCode(), chargeCodes);
|
|
|
+ if(CollUtil.isNotEmpty(tcDeptDiscountRate)){
|
|
|
+ throw new BizException("项目有套餐优惠",-2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boolean flag = false;
|
|
|
+ for(String code : chargeCodes){
|
|
|
+ Discount discount = getDiscountRate(2,null,code);
|
|
|
+ if(!(CollUtil.isNotEmpty(clinicList) && clinicList.stream().anyMatch(item->Convert.toInt(item.getZgmztczf(),0)==1)) && discount != null){
|
|
|
flag = true;
|
|
|
break;
|
|
|
}
|
|
|
+ if(StrUtil.isNotBlank(mzVisitTable.getVisitDeptCode())){
|
|
|
+ discount = getDiscountRate(0, mzVisitTable.getVisitDeptCode(),code);
|
|
|
+ if(!(CollUtil.isNotEmpty(clinicList) && clinicList.stream().anyMatch(item->Convert.toInt(item.getZgmztczf(),0)==1)) && discount !=null){
|
|
|
+ flag = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(flag){
|
|
|
+ throw new BizException("项目有单项优惠折扣",-2);
|
|
|
}
|
|
|
- }
|
|
|
- if(flag){
|
|
|
- throw new BizException("项目有单项优惠折扣",-2);
|
|
|
}
|
|
|
}
|
|
|
|