lihong 9 tháng trước cách đây
mục cha
commit
df2a46e0cc

+ 2 - 1
src/main/java/cn/hnthyy/thmz/Utils/Tools.java

@@ -806,7 +806,8 @@ public class Tools {
     }
 
     public static void main(String[] args) {
-        System.out.println(getAmPmDateDiff(DateUtil.parse("2025-01-14 17:30:00","yyyy-MM-dd HH:mm:ss"),"p"));
+        System.out.println(IdUtil.getSnowflake(2,2).nextIdStr());
+        System.out.println(IdUtil.simpleUUID());
     }
     /**
      * @description: 获取药品编码

+ 1 - 1
src/main/java/cn/hnthyy/thmz/entity/thmz/Discount.java

@@ -140,7 +140,7 @@ public class Discount extends PageBean implements Serializable {
     /**
      * 结束时间 HH:mm:ss
      */
-    private String endTime;
+    //private String endTime;
 
 
 }

+ 18 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzChargeDetailMapper.java

@@ -1223,4 +1223,22 @@ public interface MzChargeDetailMapper {
             "group by a.exec_dept,d.name  " +
             "order by type,address,name ")
     List<Map<String, Object>> getChargeDetailForGuideCard(@Param("patientId") String patientId, @Param("times") Integer times);
+    /**
+     * @description: 查询优惠后 和 未优惠的金额
+     * @author: lihong
+     * @date: 2025/3/7 16:14
+     * @param: patientId
+     * @param: times
+     * @return: cn.hnthyy.thmz.entity.his.mz.MzChargeDetail
+     **/
+    @Select(" select sum((case " +
+            "                when convert(decimal(18, 2), unit_price) = 0.00 then 0.00 " +
+            "                else convert(decimal(18, 2), unit_price) end) * quantity * drug_win) amount, " +
+            "       sum((case " +
+            "                when convert(decimal(18, 2), orig_price) = 0.00 then 0.00 " +
+            "                else convert(decimal(18, 2), orig_price) end) * quantity * drug_win) not_discount_amount " +
+            " from mz_charge_detail " +
+            " where patient_id = #{patientId} " +
+            "  and times = #{times} ")
+    MzChargeDetail selectSumTotalFee(@Param("patientId") String patientId, @Param("times")Integer times);
 }

+ 2 - 0
src/main/java/cn/hnthyy/thmz/service/his/mz/MzChargeDetailService.java

@@ -627,4 +627,6 @@ public interface MzChargeDetailService {
      * @return: java.lang.String
      **/
     String getYpHealthEducation(List<MzChargeDetail> mzChargeDetailList);
+
+    MzChargeDetail querySumTotalFee(String patientId, Integer times);
 }

+ 5 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzChargeDetailServiceImpl.java

@@ -7488,4 +7488,9 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
         List<String> ypCodeList = collect.stream().map(MzChargeDetail::getChargeItemCode).collect(Collectors.toList());
         return ypZdDictService.getHealthContent(ypCodeList);
     }
+
+    @Override
+    public MzChargeDetail querySumTotalFee(String patientId, Integer times) {
+        return mzChargeDetailMapper.selectSumTotalFee(patientId,times);
+    }
 }

+ 1 - 1
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzyRequestServiceImpl.java

@@ -559,7 +559,7 @@ public class MzyRequestServiceImpl implements MzyRequestService {
                 }
                 BigDecimal tempFee = checkFee.multiply(BigDecimal.valueOf(0.5));
                 mzyZdChargeType.setOthFee(mzyZdChargeType.getOthFee().add(tempFee));
-                mzyZdChargeType.setMessage("根据【湘医保发〔2020〕51 号】价格通知,6岁以内的小朋友挂号费上调50%!");
+                mzyZdChargeType.setMessage("根据【湘医保发〔2020〕51 号】价格通知,不满7周岁的儿童挂号费上调50%!");
             }
         }
         //看病人身份是是否有挂号优惠

+ 60 - 42
src/main/java/cn/hnthyy/thmz/service/impl/thmz/DiscountServiceImpl.java

@@ -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);
         }
     }
 

+ 2 - 2
src/main/resources/static/js/mz/clinic.js

@@ -5414,7 +5414,7 @@ function saveJyJcItem(calculateTotalAmountFlag) {
                         var xlCode = res.data.xlCode;
                         xlCode = Multiply(100, xlCode);
                         $("#messageModal").modal();
-                        $("#messageContent").html("根据【湘医保发〔2020〕51 号】价格通知,6岁以内的小朋友诊疗费上调" + xlCode + "%,是否需要继续添加该项目?");
+                        $("#messageContent").html("根据【湘医保发〔2020〕51 号】价格通知,不满7周岁的儿童诊疗费上调" + xlCode + "%,是否需要继续添加该项目?");
                         $("#messageButton").off("click").on("click", function (t) {
                             $("#messageModal").modal("hide");
                             saveJyJcItemReal(calculateTotalAmountFlag);
@@ -5758,7 +5758,7 @@ function saveZlItem(calculateTotalAmountFlag) {
                         var xlCode = res.data.xlCode;
                         xlCode = Multiply(100, xlCode);
                         $("#messageModal").modal();
-                        $("#messageContent").html("根据【湘医保发〔2020〕51 号】价格通知,6岁以内的小朋友诊疗费上调" + xlCode + "%,是否需要继续添加该项目?");
+                        $("#messageContent").html("根据【湘医保发〔2020〕51 号】价格通知,不满7周岁的儿童诊疗费上调" + xlCode + "%,是否需要继续添加该项目?");
                         $("#messageButton").off("click").on("click", function (t) {
                             $("#messageModal").modal("hide");
                             saveZlItemReal(calculateTotalAmountFlag);